From 37a9536eefacb34a12162802ded4b16820c1ed94 Mon Sep 17 00:00:00 2001 From: Ziin Date: Fri, 4 Jul 2025 19:12:37 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=B7=BB=E5=8A=A0=E5=A4=A7=E5=93=A5=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bigbrother/BigBrotherController.java | 107 ++++++++++++++++++ .../bigbrother/vo/BigBrotherPageReqVO.java | 56 +++++++++ .../admin/bigbrother/vo/BigBrotherRespVO.java | 71 ++++++++++++ .../bigbrother/vo/BigBrotherSaveReqVO.java | 52 +++++++++ .../dataobject/bigbrother/BigBrotherDO.java | 80 +++++++++++++ .../mysql/bigbrother/BigBrotherMapper.java | 38 +++++++ .../tkdata/enums/ErrorCodeConstants.java | 1 + .../service/bigbrother/BigBrotherService.java | 63 +++++++++++ .../bigbrother/BigBrotherServiceImpl.java | 95 ++++++++++++++++ 9 files changed, 563 insertions(+) create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/BigBrotherController.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherPageReqVO.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherRespVO.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherSaveReqVO.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/dataobject/bigbrother/BigBrotherDO.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/mysql/bigbrother/BigBrotherMapper.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherService.java create mode 100644 tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherServiceImpl.java diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/BigBrotherController.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/BigBrotherController.java new file mode 100644 index 0000000..a9594d7 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/BigBrotherController.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother; + +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherRespVO; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherSaveReqVO; +import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO; +import cn.iocoder.yudao.module.tkdata.service.bigbrother.BigBrotherService; +import org.springframework.web.bind.annotation.*; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.security.access.prepost.PreAuthorize; +import io.swagger.v3.oas.annotations.tags.Tag; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Operation; + +import javax.validation.constraints.*; +import javax.validation.*; +import javax.servlet.http.*; +import java.util.*; +import java.io.IOException; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.*; + + + +@Tag(name = "管理后台 - 大哥数据") +@RestController +@RequestMapping("/server/big-brother") +@Validated +public class BigBrotherController { + + @Resource + private BigBrotherService bigBrotherService; + + @PostMapping("/create") + @Operation(summary = "创建大哥数据") + @PreAuthorize("@ss.hasPermission('server:big-brother:create')") + public CommonResult createBigBrother(@Valid @RequestBody BigBrotherSaveReqVO createReqVO) { + return success(bigBrotherService.createBigBrother(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新大哥数据") + @PreAuthorize("@ss.hasPermission('server:big-brother:update')") + public CommonResult updateBigBrother(@Valid @RequestBody BigBrotherSaveReqVO updateReqVO) { + bigBrotherService.updateBigBrother(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除大哥数据") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('server:big-brother:delete')") + public CommonResult deleteBigBrother(@RequestParam("id") Integer id) { + bigBrotherService.deleteBigBrother(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除大哥数据") + @PreAuthorize("@ss.hasPermission('server:big-brother:delete')") + public CommonResult deleteBigBrotherList(@RequestParam("ids") List ids) { + bigBrotherService.deleteBigBrotherListByIds(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得大哥数据") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('server:big-brother:query')") + public CommonResult getBigBrother(@RequestParam("id") Integer id) { + BigBrotherDO bigBrother = bigBrotherService.getBigBrother(id); + return success(BeanUtils.toBean(bigBrother, BigBrotherRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得大哥数据分页") + @PreAuthorize("@ss.hasPermission('server:big-brother:query')") + public CommonResult> getBigBrotherPage(@Valid BigBrotherPageReqVO pageReqVO) { + PageResult pageResult = bigBrotherService.getBigBrotherPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, BigBrotherRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出大哥数据 Excel") + @PreAuthorize("@ss.hasPermission('server:big-brother:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportBigBrotherExcel(@Valid BigBrotherPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = bigBrotherService.getBigBrotherPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "大哥数据.xls", "数据", BigBrotherRespVO.class, + BeanUtils.toBean(list, BigBrotherRespVO.class)); + } + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherPageReqVO.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherPageReqVO.java new file mode 100644 index 0000000..3941227 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherPageReqVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo; + +import lombok.*; +import java.util.*; +import io.swagger.v3.oas.annotations.media.Schema; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - 大哥数据分页 Request VO") +@Data +public class BigBrotherPageReqVO extends PageParam { + + @Schema(description = "大哥的display_id", example = "862") + private String displayId; + + @Schema(description = "大哥的用户id") + private String userIdStr; + + @Schema(description = "大哥的用户昵称", example = "李四") + private String nickname; + + @Schema(description = "大哥的等级") + private Integer level; + + @Schema(description = "大哥打赏的金币") + private Integer hostcoins; + + @Schema(description = "大哥的粉丝数", example = "29086") + private Integer followerCount; + + @Schema(description = "大哥的关注数", example = "18376") + private Integer followingCount; + + @Schema(description = "大哥所在的地区") + private String region; + + @Schema(description = "大哥打赏的历史最高金币") + private Integer historicHighCoins; + + @Schema(description = "大哥历史打赏金币总和") + private Integer totalGiftCoins; + + @Schema(description = "大哥所在的直播间的主播display_id", example = "22001") + private String hostDisplayId; + + @Schema(description = "该数据所属的账号id", example = "30487") + private String ownerId; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherRespVO.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherRespVO.java new file mode 100644 index 0000000..be1ebe7 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherRespVO.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; +import com.alibaba.excel.annotation.*; + +@Schema(description = "管理后台 - 大哥数据 Response VO") +@Data +@ExcelIgnoreUnannotated +public class BigBrotherRespVO { + + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22765") + @ExcelProperty("主键id") + private Integer id; + + @Schema(description = "大哥的display_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "862") + @ExcelProperty("大哥的display_id") + private String displayId; + + @Schema(description = "大哥的用户id") + @ExcelProperty("大哥的用户id") + private String userIdStr; + + @Schema(description = "大哥的用户昵称", example = "李四") + @ExcelProperty("大哥的用户昵称") + private String nickname; + + @Schema(description = "大哥的等级") + @ExcelProperty("大哥的等级") + private Integer level; + + @Schema(description = "大哥打赏的金币") + @ExcelProperty("大哥打赏的金币") + private Integer hostcoins; + + @Schema(description = "大哥的粉丝数", example = "29086") + @ExcelProperty("大哥的粉丝数") + private Integer followerCount; + + @Schema(description = "大哥的关注数", example = "18376") + @ExcelProperty("大哥的关注数") + private Integer followingCount; + + @Schema(description = "大哥所在的地区") + @ExcelProperty("大哥所在的地区") + private String region; + + @Schema(description = "大哥打赏的历史最高金币") + @ExcelProperty("大哥打赏的历史最高金币") + private Integer historicHighCoins; + + @Schema(description = "大哥历史打赏金币总和") + @ExcelProperty("大哥历史打赏金币总和") + private Integer totalGiftCoins; + + @Schema(description = "大哥所在的直播间的主播display_id", example = "22001") + @ExcelProperty("大哥所在的直播间的主播display_id") + private String hostDisplayId; + + @Schema(description = "该数据所属的账号id", example = "30487") + @ExcelProperty("该数据所属的账号id") + private String ownerId; + + @Schema(description = "创建时间") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherSaveReqVO.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherSaveReqVO.java new file mode 100644 index 0000000..a3c39b5 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/controller/admin/bigbrother/vo/BigBrotherSaveReqVO.java @@ -0,0 +1,52 @@ +package cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; + +@Schema(description = "管理后台 - 大哥数据新增/修改 Request VO") +@Data +public class BigBrotherSaveReqVO { + + @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "22765") + private Integer id; + + @Schema(description = "大哥的display_id", requiredMode = Schema.RequiredMode.REQUIRED, example = "862") + @NotEmpty(message = "大哥的display_id不能为空") + private String displayId; + + @Schema(description = "大哥的用户id") + private String userIdStr; + + @Schema(description = "大哥的用户昵称", example = "李四") + private String nickname; + + @Schema(description = "大哥的等级") + private Integer level; + + @Schema(description = "大哥打赏的金币") + private Integer hostcoins; + + @Schema(description = "大哥的粉丝数", example = "29086") + private Integer followerCount; + + @Schema(description = "大哥的关注数", example = "18376") + private Integer followingCount; + + @Schema(description = "大哥所在的地区") + private String region; + + @Schema(description = "大哥打赏的历史最高金币") + private Integer historicHighCoins; + + @Schema(description = "大哥历史打赏金币总和") + private Integer totalGiftCoins; + + @Schema(description = "大哥所在的直播间的主播display_id", example = "22001") + private String hostDisplayId; + + @Schema(description = "该数据所属的账号id", example = "30487") + private String ownerId; + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/dataobject/bigbrother/BigBrotherDO.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/dataobject/bigbrother/BigBrotherDO.java new file mode 100644 index 0000000..32c98f1 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/dataobject/bigbrother/BigBrotherDO.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 大哥数据 DO + * + * @author 总后台 + */ +@TableName("server_big_brother") +@KeySequence("server_big_brother_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class BigBrotherDO extends BaseDO { + + /** + * 主键id + */ + @TableId + private Integer id; + /** + * 大哥的display_id + */ + private String displayId; + /** + * 大哥的用户id + */ + private String userIdStr; + /** + * 大哥的用户昵称 + */ + private String nickname; + /** + * 大哥的等级 + */ + private Integer level; + /** + * 大哥打赏的金币 + */ + private Integer hostcoins; + /** + * 大哥的粉丝数 + */ + private Integer followerCount; + /** + * 大哥的关注数 + */ + private Integer followingCount; + /** + * 大哥所在的地区 + */ + private String region; + /** + * 大哥打赏的历史最高金币 + */ + private Integer historicHighCoins; + /** + * 大哥历史打赏金币总和 + */ + private Integer totalGiftCoins; + /** + * 大哥所在的直播间的主播display_id + */ + private String hostDisplayId; + /** + * 该数据所属的账号id + */ + private String ownerId; + + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/mysql/bigbrother/BigBrotherMapper.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/mysql/bigbrother/BigBrotherMapper.java new file mode 100644 index 0000000..a9f558e --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/dal/mysql/bigbrother/BigBrotherMapper.java @@ -0,0 +1,38 @@ +package cn.iocoder.yudao.module.tkdata.dal.mysql.bigbrother; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO; +import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * 大哥数据 Mapper + * + * @author 总后台 + */ +@Mapper +public interface BigBrotherMapper extends BaseMapperX { + + default PageResult selectPage(BigBrotherPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(BigBrotherDO::getDisplayId, reqVO.getDisplayId()) + .eqIfPresent(BigBrotherDO::getUserIdStr, reqVO.getUserIdStr()) + .likeIfPresent(BigBrotherDO::getNickname, reqVO.getNickname()) + .eqIfPresent(BigBrotherDO::getLevel, reqVO.getLevel()) + .eqIfPresent(BigBrotherDO::getHostcoins, reqVO.getHostcoins()) + .eqIfPresent(BigBrotherDO::getFollowerCount, reqVO.getFollowerCount()) + .eqIfPresent(BigBrotherDO::getFollowingCount, reqVO.getFollowingCount()) + .eqIfPresent(BigBrotherDO::getRegion, reqVO.getRegion()) + .eqIfPresent(BigBrotherDO::getHistoricHighCoins, reqVO.getHistoricHighCoins()) + .eqIfPresent(BigBrotherDO::getTotalGiftCoins, reqVO.getTotalGiftCoins()) + .eqIfPresent(BigBrotherDO::getHostDisplayId, reqVO.getHostDisplayId()) + .eqIfPresent(BigBrotherDO::getOwnerId, reqVO.getOwnerId()) + .betweenIfPresent(BigBrotherDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(BigBrotherDO::getId)); + } + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/enums/ErrorCodeConstants.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/enums/ErrorCodeConstants.java index 01ba14b..9933b53 100644 --- a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/enums/ErrorCodeConstants.java +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/enums/ErrorCodeConstants.java @@ -12,4 +12,5 @@ public interface ErrorCodeConstants { //===============主播信息 1_001_300_000================= ErrorCode NEW_HOSTS_NOT_EXISTS = new ErrorCode(1_001_301_000, "主播数据不存在"); ErrorCode EMPLOYEE_HOSTS_NOT_EXISTS = new ErrorCode(1_001_301_001, "分配员工数据不存在"); + ErrorCode BIG_BROTHER_NOT_EXISTS = new ErrorCode(1_001_401_001, "大哥数据不存在"); } diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherService.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherService.java new file mode 100644 index 0000000..1d2c900 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherService.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.tkdata.service.bigbrother; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherSaveReqVO; +import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO; + +/** + * 大哥数据 Service 接口 + * + * @author 总后台 + */ +public interface BigBrotherService { + + /** + * 创建大哥数据 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Integer createBigBrother(@Valid BigBrotherSaveReqVO createReqVO); + + /** + * 更新大哥数据 + * + * @param updateReqVO 更新信息 + */ + void updateBigBrother(@Valid BigBrotherSaveReqVO updateReqVO); + + /** + * 删除大哥数据 + * + * @param id 编号 + */ + void deleteBigBrother(Integer id); + + /** + * 批量删除大哥数据 + * + * @param ids 编号 + */ + void deleteBigBrotherListByIds(List ids); + + /** + * 获得大哥数据 + * + * @param id 编号 + * @return 大哥数据 + */ + BigBrotherDO getBigBrother(Integer id); + + /** + * 获得大哥数据分页 + * + * @param pageReqVO 分页查询 + * @return 大哥数据分页 + */ + PageResult getBigBrotherPage(BigBrotherPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherServiceImpl.java b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherServiceImpl.java new file mode 100644 index 0000000..80f7429 --- /dev/null +++ b/tkdata-model-server/src/main/java/cn/iocoder/yudao/module/tkdata/service/bigbrother/BigBrotherServiceImpl.java @@ -0,0 +1,95 @@ +package cn.iocoder.yudao.module.tkdata.service.bigbrother; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherPageReqVO; +import cn.iocoder.yudao.module.tkdata.controller.admin.bigbrother.vo.BigBrotherSaveReqVO; +import cn.iocoder.yudao.module.tkdata.dal.dataobject.bigbrother.BigBrotherDO; +import cn.iocoder.yudao.module.tkdata.dal.mysql.bigbrother.BigBrotherMapper; +import org.springframework.stereotype.Service; +import javax.annotation.Resource; +import org.springframework.validation.annotation.Validated; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; + + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.diffList; +import static cn.iocoder.yudao.module.tkdata.enums.ErrorCodeConstants.BIG_BROTHER_NOT_EXISTS; + + +/** + * 大哥数据 Service 实现类 + * + * @author 总后台 + */ +@Service +@Validated +public class BigBrotherServiceImpl implements BigBrotherService { + + @Resource + private BigBrotherMapper bigBrotherMapper; + + @Override + public Integer createBigBrother(BigBrotherSaveReqVO createReqVO) { + // 插入 + BigBrotherDO bigBrother = BeanUtils.toBean(createReqVO, BigBrotherDO.class); + bigBrotherMapper.insert(bigBrother); + // 返回 + return bigBrother.getId(); + } + + @Override + public void updateBigBrother(BigBrotherSaveReqVO updateReqVO) { + // 校验存在 + validateBigBrotherExists(updateReqVO.getId()); + // 更新 + BigBrotherDO updateObj = BeanUtils.toBean(updateReqVO, BigBrotherDO.class); + bigBrotherMapper.updateById(updateObj); + } + + @Override + public void deleteBigBrother(Integer id) { + // 校验存在 + validateBigBrotherExists(id); + // 删除 + bigBrotherMapper.deleteById(id); + } + + @Override + public void deleteBigBrotherListByIds(List ids) { + // 校验存在 + validateBigBrotherExists(ids); + // 删除 + bigBrotherMapper.deleteByIds(ids); + } + + private void validateBigBrotherExists(List ids) { + List list = bigBrotherMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(BIG_BROTHER_NOT_EXISTS); + } + } + + private void validateBigBrotherExists(Integer id) { + if (bigBrotherMapper.selectById(id) == null) { + throw exception(BIG_BROTHER_NOT_EXISTS); + } + } + + @Override + public BigBrotherDO getBigBrother(Integer id) { + return bigBrotherMapper.selectById(id); + } + + @Override + public PageResult getBigBrotherPage(BigBrotherPageReqVO pageReqVO) { + return bigBrotherMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file