Commit 9ce50ec369b450b8e55b6b75d9cce3229a68d7c8
1 parent
26981644
CRM-客户限制配置:VO 简化
Showing
10 changed files
with
94 additions
and
72 deletions
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerLimitConfigController.java
| ... | ... | @@ -3,10 +3,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; |
| 8 | 7 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; |
| 9 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | |
| 8 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | |
| 10 | 9 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; |
| 11 | 10 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 12 | 11 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigService; |
| ... | ... | @@ -17,12 +16,12 @@ import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 17 | 16 | import io.swagger.v3.oas.annotations.Operation; |
| 18 | 17 | import io.swagger.v3.oas.annotations.Parameter; |
| 19 | 18 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 19 | +import jakarta.annotation.Resource; | |
| 20 | +import jakarta.validation.Valid; | |
| 20 | 21 | import org.springframework.security.access.prepost.PreAuthorize; |
| 21 | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | 23 | import org.springframework.web.bind.annotation.*; |
| 23 | 24 | |
| 24 | -import jakarta.annotation.Resource; | |
| 25 | -import jakarta.validation.Valid; | |
| 26 | 25 | import java.util.Collection; |
| 27 | 26 | import java.util.Map; |
| 28 | 27 | |
| ... | ... | @@ -43,18 +42,17 @@ public class CrmCustomerLimitConfigController { |
| 43 | 42 | @Resource |
| 44 | 43 | private AdminUserApi adminUserApi; |
| 45 | 44 | |
| 46 | - // TODO @puhui999:可以把 vo 改下哈 | |
| 47 | 45 | @PostMapping("/create") |
| 48 | 46 | @Operation(summary = "创建客户限制配置") |
| 49 | 47 | @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:create')") |
| 50 | - public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigCreateReqVO createReqVO) { | |
| 48 | + public CommonResult<Long> createCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO createReqVO) { | |
| 51 | 49 | return success(customerLimitConfigService.createCustomerLimitConfig(createReqVO)); |
| 52 | 50 | } |
| 53 | 51 | |
| 54 | 52 | @PutMapping("/update") |
| 55 | 53 | @Operation(summary = "更新客户限制配置") |
| 56 | 54 | @PreAuthorize("@ss.hasPermission('crm:customer-limit-config:update')") |
| 57 | - public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigUpdateReqVO updateReqVO) { | |
| 55 | + public CommonResult<Boolean> updateCustomerLimitConfig(@Valid @RequestBody CrmCustomerLimitConfigSaveReqVO updateReqVO) { | |
| 58 | 56 | customerLimitConfigService.updateCustomerLimitConfig(updateReqVO); |
| 59 | 57 | return success(true); |
| 60 | 58 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigCreateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | - | |
| 8 | -@Schema(description = "管理后台 - 客户限制配置创建 Request VO") | |
| 9 | -@Data | |
| 10 | -@EqualsAndHashCode(callSuper = true) | |
| 11 | -@ToString(callSuper = true) | |
| 12 | -public class CrmCustomerLimitConfigCreateReqVO extends CrmCustomerLimitConfigBaseVO { | |
| 13 | - | |
| 14 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java
| ... | ... | @@ -3,22 +3,36 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; |
| 3 | 3 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 4 | 4 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 5 | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | +import jakarta.validation.constraints.NotNull; | |
| 6 | 7 | import lombok.Data; |
| 7 | -import lombok.EqualsAndHashCode; | |
| 8 | -import lombok.ToString; | |
| 9 | 8 | |
| 10 | 9 | import java.time.LocalDateTime; |
| 11 | 10 | import java.util.List; |
| 12 | 11 | |
| 13 | 12 | @Schema(description = "管理后台 - 客户限制配置 Response VO") |
| 14 | 13 | @Data |
| 15 | -@EqualsAndHashCode(callSuper = true) | |
| 16 | -@ToString(callSuper = true) | |
| 17 | -public class CrmCustomerLimitConfigRespVO extends CrmCustomerLimitConfigBaseVO { | |
| 14 | +public class CrmCustomerLimitConfigRespVO { | |
| 18 | 15 | |
| 19 | 16 | @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") |
| 20 | 17 | private Long id; |
| 21 | 18 | |
| 19 | + @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") | |
| 20 | + @NotNull(message = "规则类型不能为空") | |
| 21 | + private Integer type; | |
| 22 | + | |
| 23 | + @Schema(description = "规则适用人群") | |
| 24 | + private List<Long> userIds; | |
| 25 | + | |
| 26 | + @Schema(description = "规则适用部门") | |
| 27 | + private List<Long> deptIds; | |
| 28 | + | |
| 29 | + @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") | |
| 30 | + @NotNull(message = "数量上限不能为空") | |
| 31 | + private Integer maxCount; | |
| 32 | + | |
| 33 | + @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") | |
| 34 | + private Boolean dealCountEnabled; | |
| 35 | + | |
| 22 | 36 | @Schema(description = "规则适用人群名称") |
| 23 | 37 | private List<AdminUserRespDTO> users; |
| 24 | 38 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigBaseVO.java renamed to yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; |
| 2 | 2 | |
| 3 | +import com.mzt.logapi.starter.annotation.DiffLogField; | |
| 3 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 5 | +import jakarta.validation.constraints.NotNull; | |
| 4 | 6 | import lombok.Data; |
| 5 | 7 | |
| 6 | -import jakarta.validation.constraints.NotNull; | |
| 7 | 8 | import java.util.List; |
| 8 | 9 | |
| 9 | -/** | |
| 10 | - * 客户限制配置 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 11 | - * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 12 | - */ | |
| 10 | +@Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO") | |
| 13 | 11 | @Data |
| 14 | -public class CrmCustomerLimitConfigBaseVO { | |
| 12 | +public class CrmCustomerLimitConfigSaveReqVO { | |
| 13 | + | |
| 14 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") | |
| 15 | + private Long id; | |
| 15 | 16 | |
| 16 | 17 | @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") |
| 18 | + @DiffLogField(name = "规则类型") | |
| 17 | 19 | @NotNull(message = "规则类型不能为空") |
| 18 | 20 | private Integer type; |
| 19 | 21 | |
| 20 | 22 | @Schema(description = "规则适用人群") |
| 23 | + @DiffLogField(name = "规则适用人群", function = "getAdminUserById") | |
| 21 | 24 | private List<Long> userIds; |
| 22 | 25 | |
| 23 | 26 | @Schema(description = "规则适用部门") |
| 27 | + @DiffLogField(name = "规则适用部门", function = "getDeptById") | |
| 24 | 28 | private List<Long> deptIds; |
| 25 | 29 | |
| 26 | 30 | @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") |
| 31 | + @DiffLogField(name = "数量上限") | |
| 27 | 32 | @NotNull(message = "数量上限不能为空") |
| 28 | 33 | private Integer maxCount; |
| 29 | 34 | |
| 30 | 35 | @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") |
| 36 | + @DiffLogField(name = "成交客户是否占有拥有客户数") | |
| 31 | 37 | private Boolean dealCountEnabled; |
| 32 | 38 | |
| 33 | 39 | } | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigUpdateReqVO.java deleted
| 1 | -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; | |
| 2 | - | |
| 3 | -import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | -import lombok.Data; | |
| 5 | -import lombok.EqualsAndHashCode; | |
| 6 | -import lombok.ToString; | |
| 7 | - | |
| 8 | -import jakarta.validation.constraints.NotNull; | |
| 9 | - | |
| 10 | -@Schema(description = "管理后台 - 客户限制配置更新 Request VO") | |
| 11 | -@Data | |
| 12 | -@EqualsAndHashCode(callSuper = true) | |
| 13 | -@ToString(callSuper = true) | |
| 14 | -public class CrmCustomerLimitConfigUpdateReqVO extends CrmCustomerLimitConfigBaseVO { | |
| 15 | - | |
| 16 | - @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "27930") | |
| 17 | - @NotNull(message = "编号不能为空") | |
| 18 | - private Long id; | |
| 19 | - | |
| 20 | -} |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 5 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; |
| 6 | 6 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | |
| 8 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 9 | 9 | import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; |
| 10 | 10 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| ... | ... | @@ -26,7 +26,7 @@ public interface CrmCustomerLimitConfigConvert { |
| 26 | 26 | |
| 27 | 27 | CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigCreateReqVO bean); |
| 28 | 28 | |
| 29 | - CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigUpdateReqVO bean); | |
| 29 | + CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); | |
| 30 | 30 | |
| 31 | 31 | CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); |
| 32 | 32 | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigService.java
| 1 | 1 | package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | |
| 5 | 4 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; |
| 6 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | |
| 7 | 6 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 8 | 7 | import jakarta.validation.Valid; |
| 9 | 8 | |
| ... | ... | @@ -22,14 +21,14 @@ public interface CrmCustomerLimitConfigService { |
| 22 | 21 | * @param createReqVO 创建信息 |
| 23 | 22 | * @return 编号 |
| 24 | 23 | */ |
| 25 | - Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigCreateReqVO createReqVO); | |
| 24 | + Long createCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO createReqVO); | |
| 26 | 25 | |
| 27 | 26 | /** |
| 28 | 27 | * 更新客户限制配置 |
| 29 | 28 | * |
| 30 | 29 | * @param updateReqVO 更新信息 |
| 31 | 30 | */ |
| 32 | - void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigUpdateReqVO updateReqVO); | |
| 31 | + void updateCustomerLimitConfig(@Valid CrmCustomerLimitConfigSaveReqVO updateReqVO); | |
| 33 | 32 | |
| 34 | 33 | /** |
| 35 | 34 | * 删除客户限制配置 |
| ... | ... | @@ -57,7 +56,7 @@ public interface CrmCustomerLimitConfigService { |
| 57 | 56 | /** |
| 58 | 57 | * 查询用户对应的配置列表 |
| 59 | 58 | * |
| 60 | - * @param type 类型 | |
| 59 | + * @param type 类型 | |
| 61 | 60 | * @param userId 用户类型 |
| 62 | 61 | */ |
| 63 | 62 | List<CrmCustomerLimitConfigDO> getCustomerLimitConfigListByUserId(Integer type, Long userId); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java
| ... | ... | @@ -2,20 +2,18 @@ package cn.iocoder.yudao.module.crm.service.customer; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | |
| 8 | 7 | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; |
| 9 | 8 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; |
| 11 | 10 | import cn.iocoder.yudao.module.system.api.dept.DeptApi; |
| 12 | 11 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 13 | 12 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 13 | +import jakarta.annotation.Resource; | |
| 14 | 14 | import org.springframework.stereotype.Service; |
| 15 | 15 | import org.springframework.validation.annotation.Validated; |
| 16 | 16 | |
| 17 | -import jakarta.annotation.Resource; | |
| 18 | - | |
| 19 | 17 | import java.util.Collection; |
| 20 | 18 | import java.util.List; |
| 21 | 19 | |
| ... | ... | @@ -41,7 +39,7 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig |
| 41 | 39 | |
| 42 | 40 | @Override |
| 43 | 41 | // TODO @puhui999:操作日志 |
| 44 | - public Long createCustomerLimitConfig(CrmCustomerLimitConfigCreateReqVO createReqVO) { | |
| 42 | + public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { | |
| 45 | 43 | validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); |
| 46 | 44 | // 插入 |
| 47 | 45 | CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); |
| ... | ... | @@ -52,7 +50,7 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig |
| 52 | 50 | |
| 53 | 51 | @Override |
| 54 | 52 | // TODO @puhui999:操作日志 |
| 55 | - public void updateCustomerLimitConfig(CrmCustomerLimitConfigUpdateReqVO updateReqVO) { | |
| 53 | + public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { | |
| 56 | 54 | // 校验存在 |
| 57 | 55 | validateCustomerLimitConfigExists(updateReqVO.getId()); |
| 58 | 56 | validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); | ... | ... |
yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customerlimitconfig/CrmCustomerLimitConfigServiceImplTest.java
| ... | ... | @@ -2,18 +2,16 @@ package cn.iocoder.yudao.module.crm.service.customerlimitconfig; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; |
| 5 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; | |
| 6 | 5 | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; |
| 7 | -import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigUpdateReqVO; | |
| 6 | +import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | |
| 8 | 7 | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; |
| 9 | 8 | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; |
| 10 | 9 | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerLimitConfigServiceImpl; |
| 10 | +import jakarta.annotation.Resource; | |
| 11 | 11 | import org.junit.jupiter.api.Disabled; |
| 12 | 12 | import org.junit.jupiter.api.Test; |
| 13 | 13 | import org.springframework.context.annotation.Import; |
| 14 | 14 | |
| 15 | -import jakarta.annotation.Resource; | |
| 16 | - | |
| 17 | 15 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; |
| 18 | 16 | import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException; |
| 19 | 17 | import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomLongId; |
| ... | ... | @@ -40,7 +38,7 @@ public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest { |
| 40 | 38 | @Test |
| 41 | 39 | public void testCreateCustomerLimitConfig_success() { |
| 42 | 40 | // 准备参数 |
| 43 | - CrmCustomerLimitConfigCreateReqVO reqVO = randomPojo(CrmCustomerLimitConfigCreateReqVO.class); | |
| 41 | + CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class); | |
| 44 | 42 | |
| 45 | 43 | // 调用 |
| 46 | 44 | Long customerLimitConfigId = customerLimitConfigService.createCustomerLimitConfig(reqVO); |
| ... | ... | @@ -57,7 +55,7 @@ public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest { |
| 57 | 55 | CrmCustomerLimitConfigDO dbCustomerLimitConfig = randomPojo(CrmCustomerLimitConfigDO.class); |
| 58 | 56 | customerLimitConfigMapper.insert(dbCustomerLimitConfig);// @Sql: 先插入出一条存在的数据 |
| 59 | 57 | // 准备参数 |
| 60 | - CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class, o -> { | |
| 58 | + CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class, o -> { | |
| 61 | 59 | o.setId(dbCustomerLimitConfig.getId()); // 设置更新的 ID |
| 62 | 60 | }); |
| 63 | 61 | |
| ... | ... | @@ -71,7 +69,7 @@ public class CrmCustomerLimitConfigServiceImplTest extends BaseDbUnitTest { |
| 71 | 69 | @Test |
| 72 | 70 | public void testUpdateCustomerLimitConfig_notExists() { |
| 73 | 71 | // 准备参数 |
| 74 | - CrmCustomerLimitConfigUpdateReqVO reqVO = randomPojo(CrmCustomerLimitConfigUpdateReqVO.class); | |
| 72 | + CrmCustomerLimitConfigSaveReqVO reqVO = randomPojo(CrmCustomerLimitConfigSaveReqVO.class); | |
| 75 | 73 | |
| 76 | 74 | // 调用, 并断言异常 |
| 77 | 75 | assertServiceException(() -> customerLimitConfigService.updateCustomerLimitConfig(reqVO), CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/operatelog/core/DeptParseFunction.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.system.framework.operatelog.core; | |
| 2 | + | |
| 3 | +import cn.hutool.core.util.StrUtil; | |
| 4 | +import cn.iocoder.yudao.module.system.api.dept.DeptApi; | |
| 5 | +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; | |
| 6 | +import com.mzt.logapi.service.IParseFunction; | |
| 7 | +import jakarta.annotation.Resource; | |
| 8 | +import lombok.extern.slf4j.Slf4j; | |
| 9 | +import org.springframework.stereotype.Component; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 管理员名字的 {@link IParseFunction} 实现类 | |
| 13 | + * | |
| 14 | + * @author HUIHUI | |
| 15 | + */ | |
| 16 | +@Slf4j | |
| 17 | +@Component | |
| 18 | +public class DeptParseFunction implements IParseFunction { | |
| 19 | + | |
| 20 | + @Resource | |
| 21 | + private DeptApi deptApi; | |
| 22 | + | |
| 23 | + @Override | |
| 24 | + public String functionName() { | |
| 25 | + return "getDeptById"; | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public String apply(Object value) { | |
| 30 | + if (StrUtil.isEmptyIfStr(value)) { | |
| 31 | + return ""; | |
| 32 | + } | |
| 33 | + | |
| 34 | + // 获取部门信息 | |
| 35 | + DeptRespDTO dept = deptApi.getDept(Long.parseLong(value.toString())); | |
| 36 | + if (dept == null) { | |
| 37 | + log.warn("[apply][获取部门{{}}为空", value); | |
| 38 | + return ""; | |
| 39 | + } | |
| 40 | + return dept.getName(); | |
| 41 | + } | |
| 42 | + | |
| 43 | +} | ... | ... |