From c75df4743d6a5f3f3841994677c19559bf6088c8 Mon Sep 17 00:00:00 2001 From: ziin Date: Wed, 19 Nov 2025 20:39:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(system):=20=E6=96=B0=E5=A2=9E=E7=A7=9F?= =?UTF-8?q?=E6=88=B7=E7=A7=AF=E5=88=86=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 新增租户积分实体、Mapper、Service及Controller全套代码,并补充对应错误码TENANT_POINTS_NOT_EXISTS。 --- .../tenantpoints/TenantPointsController.java | 104 ++++++++++++++++++ .../vo/TenantPointsPageReqVO.java | 43 ++++++++ .../tenantpoints/vo/TenantPointsRespVO.java | 55 +++++++++ .../vo/TenantPointsSaveReqVO.java | 46 ++++++++ .../tenantpoints/TenantPointsDO.java | 67 +++++++++++ .../tenantpoints/TenantPointsMapper.java | 34 ++++++ .../system/enums/ErrorCodeConstants.java | 3 + .../tenantpoints/TenantPointsService.java | 62 +++++++++++ .../tenantpoints/TenantPointsServiceImpl.java | 92 ++++++++++++++++ .../resources/mapper/TenantPointsMapper.xml | 12 ++ 10 files changed, 518 insertions(+) create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/TenantPointsController.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsPageReqVO.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsRespVO.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsSaveReqVO.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenantpoints/TenantPointsDO.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenantpoints/TenantPointsMapper.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsService.java create mode 100644 yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsServiceImpl.java create mode 100644 yudao-module-system/src/main/resources/mapper/TenantPointsMapper.xml diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/TenantPointsController.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/TenantPointsController.java new file mode 100644 index 0000000..a01cb76 --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/TenantPointsController.java @@ -0,0 +1,104 @@ +package cn.iocoder.yudao.module.system.controller.admin.tenantpoints; + +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.*; + +import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO; +import cn.iocoder.yudao.module.system.service.tenantpoints.TenantPointsService; + +@Tag(name = "管理后台 - 租户积分记录") +@RestController +@RequestMapping("/system/tenant-points") +@Validated +public class TenantPointsController { + + @Resource + private TenantPointsService tenantPointsService; + + @PostMapping("/create") + @Operation(summary = "创建租户积分记录") + @PreAuthorize("@ss.hasPermission('system:tenant-points:create')") + public CommonResult createTenantPoints(@Valid @RequestBody TenantPointsSaveReqVO createReqVO) { + return success(tenantPointsService.createTenantPoints(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新租户积分记录") + @PreAuthorize("@ss.hasPermission('system:tenant-points:update')") + public CommonResult updateTenantPoints(@Valid @RequestBody TenantPointsSaveReqVO updateReqVO) { + tenantPointsService.updateTenantPoints(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除租户积分记录") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('system:tenant-points:delete')") + public CommonResult deleteTenantPoints(@RequestParam("id") Long id) { + tenantPointsService.deleteTenantPoints(id); + return success(true); + } + + @DeleteMapping("/delete-list") + @Parameter(name = "ids", description = "编号", required = true) + @Operation(summary = "批量删除租户积分记录") + @PreAuthorize("@ss.hasPermission('system:tenant-points:delete')") + public CommonResult deleteTenantPointsList(@RequestParam("ids") List ids) { + tenantPointsService.deleteTenantPointsListByIds(ids); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得租户积分记录") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('system:tenant-points:query')") + public CommonResult getTenantPoints(@RequestParam("id") Long id) { + TenantPointsDO tenantPoints = tenantPointsService.getTenantPoints(id); + return success(BeanUtils.toBean(tenantPoints, TenantPointsRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得租户积分记录分页") + @PreAuthorize("@ss.hasPermission('system:tenant-points:query')") + public CommonResult> getTenantPointsPage(@Valid TenantPointsPageReqVO pageReqVO) { + PageResult pageResult = tenantPointsService.getTenantPointsPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, TenantPointsRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出租户积分记录 Excel") + @PreAuthorize("@ss.hasPermission('system:tenant-points:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportTenantPointsExcel(@Valid TenantPointsPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = tenantPointsService.getTenantPointsPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "租户积分记录.xls", "数据", TenantPointsRespVO.class, + BeanUtils.toBean(list, TenantPointsRespVO.class)); + } + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsPageReqVO.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsPageReqVO.java new file mode 100644 index 0000000..9162fde --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsPageReqVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.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 TenantPointsPageReqVO extends PageParam { + + @Schema(description = "本次变动点数,正加负减") + private Integer points; + + @Schema(description = "变动后余额快照(冗余)") + private Integer balance; + + @Schema(description = "变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN", example = "1") + private String type; + + @Schema(description = "变动描述", example = "随便") + private String description; + + @Schema(description = "订单 Id/业务单号", example = "84") + private Long orderId; + + @Schema(description = "业务流水号(转账、订单等唯一标识)") + private String bizNo; + + @Schema(description = "操作人 Id", example = "8171") + private Long operatorId; + + @Schema(description = "目标租户 Id(转账使用)", example = "18731") + private Long targetTenantId; + + @Schema(description = "创建时间") + private LocalDateTime createdAt; + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsRespVO.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsRespVO.java new file mode 100644 index 0000000..79b123b --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsRespVO.java @@ -0,0 +1,55 @@ +package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.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 TenantPointsRespVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16587") + @ExcelProperty("主键") + private Long id; + + @Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("本次变动点数,正加负减") + private Integer points; + + @Schema(description = "变动后余额快照(冗余)") + @ExcelProperty("变动后余额快照(冗余)") + private Integer balance; + + @Schema(description = "变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN", example = "1") + @ExcelProperty("变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN") + private String type; + + @Schema(description = "变动描述", example = "随便") + @ExcelProperty("变动描述") + private String description; + + @Schema(description = "订单 Id/业务单号", example = "84") + @ExcelProperty("订单 Id/业务单号") + private Long orderId; + + @Schema(description = "业务流水号(转账、订单等唯一标识)") + @ExcelProperty("业务流水号(转账、订单等唯一标识)") + private String bizNo; + + @Schema(description = "操作人 Id", example = "8171") + @ExcelProperty("操作人 Id") + private Long operatorId; + + @Schema(description = "目标租户 Id(转账使用)", example = "18731") + @ExcelProperty("目标租户 Id(转账使用)") + private Long targetTenantId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createdAt; + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsSaveReqVO.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsSaveReqVO.java new file mode 100644 index 0000000..d77520c --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/controller/admin/tenantpoints/vo/TenantPointsSaveReqVO.java @@ -0,0 +1,46 @@ +package cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.*; +import java.util.*; +import javax.validation.constraints.*; +import org.springframework.format.annotation.DateTimeFormat; +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - 租户积分记录新增/修改 Request VO") +@Data +public class TenantPointsSaveReqVO { + + @Schema(description = "主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "16587") + private Long id; + + @Schema(description = "本次变动点数,正加负减", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "本次变动点数,正加负减不能为空") + private Integer points; + + @Schema(description = "变动后余额快照(冗余)") + private Integer balance; + + @Schema(description = "变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN", example = "1") + private String type; + + @Schema(description = "变动描述", example = "随便") + private String description; + + @Schema(description = "订单 Id/业务单号", example = "84") + private Long orderId; + + @Schema(description = "业务流水号(转账、订单等唯一标识)") + private String bizNo; + + @Schema(description = "操作人 Id", example = "8171") + private Long operatorId; + + @Schema(description = "目标租户 Id(转账使用)", example = "18731") + private Long targetTenantId; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "创建时间不能为空") + private LocalDateTime createdAt; + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenantpoints/TenantPointsDO.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenantpoints/TenantPointsDO.java new file mode 100644 index 0000000..68e4abd --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/dataobject/tenantpoints/TenantPointsDO.java @@ -0,0 +1,67 @@ +package cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints; + +import lombok.*; +import java.util.*; +import java.time.LocalDateTime; +import com.baomidou.mybatisplus.annotation.*; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; + +/** + * 租户积分记录 DO + * + * @author 总后台 + */ +@TableName("system_tenant_points") +@KeySequence("system_tenant_points_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class TenantPointsDO extends BaseDO { + + /** + * 主键 + */ + @TableId + private Long id; + /** + * 本次变动点数,正加负减 + */ + private Integer points; + /** + * 变动后余额快照(冗余) + */ + private Integer balance; + /** + * 变动类型,如 RECHARGE, CONSUME, TRANSFER_OUT, TRANSFER_IN + */ + private String type; + /** + * 变动描述 + */ + private String description; + /** + * 订单 Id/业务单号 + */ + private Long orderId; + /** + * 业务流水号(转账、订单等唯一标识) + */ + private String bizNo; + /** + * 操作人 Id + */ + private Long operatorId; + /** + * 目标租户 Id(转账使用) + */ + private Long targetTenantId; + /** + * 创建时间 + */ + private LocalDateTime createdAt; + + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenantpoints/TenantPointsMapper.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenantpoints/TenantPointsMapper.java new file mode 100644 index 0000000..a04eb84 --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/tenantpoints/TenantPointsMapper.java @@ -0,0 +1,34 @@ +package cn.iocoder.yudao.module.system.dal.mysql.tenantpoints; + +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.system.dal.dataobject.tenantpoints.TenantPointsDO; +import org.apache.ibatis.annotations.Mapper; +import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*; + +/** + * 租户积分记录 Mapper + * + * @author 总后台 + */ +@Mapper +public interface TenantPointsMapper extends BaseMapperX { + + default PageResult selectPage(TenantPointsPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(TenantPointsDO::getPoints, reqVO.getPoints()) + .eqIfPresent(TenantPointsDO::getBalance, reqVO.getBalance()) + .eqIfPresent(TenantPointsDO::getType, reqVO.getType()) + .eqIfPresent(TenantPointsDO::getDescription, reqVO.getDescription()) + .eqIfPresent(TenantPointsDO::getOrderId, reqVO.getOrderId()) + .eqIfPresent(TenantPointsDO::getBizNo, reqVO.getBizNo()) + .eqIfPresent(TenantPointsDO::getOperatorId, reqVO.getOperatorId()) + .eqIfPresent(TenantPointsDO::getTargetTenantId, reqVO.getTargetTenantId()) + .eqIfPresent(TenantPointsDO::getCreatedAt, reqVO.getCreatedAt()) + .orderByDesc(TenantPointsDO::getId)); + } + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java index c89a5dc..cc9bb84 100644 --- a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/enums/ErrorCodeConstants.java @@ -116,6 +116,9 @@ public interface ErrorCodeConstants { ErrorCode TENANT_PACKAGE_DISABLE = new ErrorCode(1_002_016_002, "名字为【{}】的租户套餐已被禁用"); ErrorCode TENANT_PACKAGE_NAME_DUPLICATE = new ErrorCode(1_002_016_003, "已经存在该名字的租户套餐"); +// ========== 租户套餐 1-002-017-000 ========== + ErrorCode TENANT_POINTS_NOT_EXISTS = new ErrorCode(1_002_017_000, "租户积分不存在"); + // ========== 社交用户 1-002-018-000 ========== ErrorCode SOCIAL_USER_AUTH_FAILURE = new ErrorCode(1_002_018_000, "社交授权失败,原因是:{}"); ErrorCode SOCIAL_USER_NOT_FOUND = new ErrorCode(1_002_018_001, "社交授权失败,找不到对应的用户"); diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsService.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsService.java new file mode 100644 index 0000000..626fb3c --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsService.java @@ -0,0 +1,62 @@ +package cn.iocoder.yudao.module.system.service.tenantpoints; + +import java.util.*; +import javax.validation.*; +import cn.iocoder.yudao.module.system.controller.admin.tenantpoints.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; + +/** + * 租户积分记录 Service 接口 + * + * @author 总后台 + */ +public interface TenantPointsService { + + /** + * 创建租户积分记录 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createTenantPoints(@Valid TenantPointsSaveReqVO createReqVO); + + /** + * 更新租户积分记录 + * + * @param updateReqVO 更新信息 + */ + void updateTenantPoints(@Valid TenantPointsSaveReqVO updateReqVO); + + /** + * 删除租户积分记录 + * + * @param id 编号 + */ + void deleteTenantPoints(Long id); + + /** + * 批量删除租户积分记录 + * + * @param ids 编号 + */ + void deleteTenantPointsListByIds(List ids); + + /** + * 获得租户积分记录 + * + * @param id 编号 + * @return 租户积分记录 + */ + TenantPointsDO getTenantPoints(Long id); + + /** + * 获得租户积分记录分页 + * + * @param pageReqVO 分页查询 + * @return 租户积分记录分页 + */ + PageResult getTenantPointsPage(TenantPointsPageReqVO pageReqVO); + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsServiceImpl.java b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsServiceImpl.java new file mode 100644 index 0000000..6a5b3aa --- /dev/null +++ b/yudao-module-system/src/main/java/cn/iocoder/yudao/module/system/service/tenantpoints/TenantPointsServiceImpl.java @@ -0,0 +1,92 @@ +package cn.iocoder.yudao.module.system.service.tenantpoints; + +import cn.hutool.core.collection.CollUtil; +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.module.system.controller.admin.tenantpoints.vo.*; +import cn.iocoder.yudao.module.system.dal.dataobject.tenantpoints.TenantPointsDO; +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 cn.iocoder.yudao.module.system.dal.mysql.tenantpoints.TenantPointsMapper; + +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.system.enums.ErrorCodeConstants.*; + +/** + * 租户积分记录 Service 实现类 + * + * @author 总后台 + */ +@Service +@Validated +public class TenantPointsServiceImpl implements TenantPointsService { + + @Resource + private TenantPointsMapper tenantPointsMapper; + + @Override + public Long createTenantPoints(TenantPointsSaveReqVO createReqVO) { + // 插入 + TenantPointsDO tenantPoints = BeanUtils.toBean(createReqVO, TenantPointsDO.class); + tenantPointsMapper.insert(tenantPoints); + // 返回 + return tenantPoints.getId(); + } + + @Override + public void updateTenantPoints(TenantPointsSaveReqVO updateReqVO) { + // 校验存在 + validateTenantPointsExists(updateReqVO.getId()); + // 更新 + TenantPointsDO updateObj = BeanUtils.toBean(updateReqVO, TenantPointsDO.class); + tenantPointsMapper.updateById(updateObj); + } + + @Override + public void deleteTenantPoints(Long id) { + // 校验存在 + validateTenantPointsExists(id); + // 删除 + tenantPointsMapper.deleteById(id); + } + + @Override + public void deleteTenantPointsListByIds(List ids) { + // 校验存在 + validateTenantPointsExists(ids); + // 删除 + tenantPointsMapper.deleteByIds(ids); + } + + private void validateTenantPointsExists(List ids) { + List list = tenantPointsMapper.selectByIds(ids); + if (CollUtil.isEmpty(list) || list.size() != ids.size()) { + throw exception(TENANT_POINTS_NOT_EXISTS); + } + } + + private void validateTenantPointsExists(Long id) { + if (tenantPointsMapper.selectById(id) == null) { + throw exception(TENANT_POINTS_NOT_EXISTS); + } + } + + @Override + public TenantPointsDO getTenantPoints(Long id) { + return tenantPointsMapper.selectById(id); + } + + @Override + public PageResult getTenantPointsPage(TenantPointsPageReqVO pageReqVO) { + return tenantPointsMapper.selectPage(pageReqVO); + } + +} \ No newline at end of file diff --git a/yudao-module-system/src/main/resources/mapper/TenantPointsMapper.xml b/yudao-module-system/src/main/resources/mapper/TenantPointsMapper.xml new file mode 100644 index 0000000..94a3d7d --- /dev/null +++ b/yudao-module-system/src/main/resources/mapper/TenantPointsMapper.xml @@ -0,0 +1,12 @@ + + + + + + + \ No newline at end of file