1.添加大哥管理接口
This commit is contained in:
@@ -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<Integer> createBigBrother(@Valid @RequestBody BigBrotherSaveReqVO createReqVO) {
|
||||
return success(bigBrotherService.createBigBrother(createReqVO));
|
||||
}
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新大哥数据")
|
||||
@PreAuthorize("@ss.hasPermission('server:big-brother:update')")
|
||||
public CommonResult<Boolean> 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<Boolean> 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<Boolean> deleteBigBrotherList(@RequestParam("ids") List<Integer> 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<BigBrotherRespVO> 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<PageResult<BigBrotherRespVO>> getBigBrotherPage(@Valid BigBrotherPageReqVO pageReqVO) {
|
||||
PageResult<BigBrotherDO> 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<BigBrotherDO> list = bigBrotherService.getBigBrotherPage(pageReqVO).getList();
|
||||
// 导出 Excel
|
||||
ExcelUtils.write(response, "大哥数据.xls", "数据", BigBrotherRespVO.class,
|
||||
BeanUtils.toBean(list, BigBrotherRespVO.class));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
|
||||
}
|
||||
@@ -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<BigBrotherDO> {
|
||||
|
||||
default PageResult<BigBrotherDO> selectPage(BigBrotherPageReqVO reqVO) {
|
||||
return selectPage(reqVO, new LambdaQueryWrapperX<BigBrotherDO>()
|
||||
.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));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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, "大哥数据不存在");
|
||||
}
|
||||
|
||||
@@ -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<Integer> ids);
|
||||
|
||||
/**
|
||||
* 获得大哥数据
|
||||
*
|
||||
* @param id 编号
|
||||
* @return 大哥数据
|
||||
*/
|
||||
BigBrotherDO getBigBrother(Integer id);
|
||||
|
||||
/**
|
||||
* 获得大哥数据分页
|
||||
*
|
||||
* @param pageReqVO 分页查询
|
||||
* @return 大哥数据分页
|
||||
*/
|
||||
PageResult<BigBrotherDO> getBigBrotherPage(BigBrotherPageReqVO pageReqVO);
|
||||
|
||||
}
|
||||
@@ -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<Integer> ids) {
|
||||
// 校验存在
|
||||
validateBigBrotherExists(ids);
|
||||
// 删除
|
||||
bigBrotherMapper.deleteByIds(ids);
|
||||
}
|
||||
|
||||
private void validateBigBrotherExists(List<Integer> ids) {
|
||||
List<BigBrotherDO> 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<BigBrotherDO> getBigBrotherPage(BigBrotherPageReqVO pageReqVO) {
|
||||
return bigBrotherMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user