diff --git a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java index 896a1e39a..01d2e80eb 100644 --- a/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java +++ b/yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java @@ -122,6 +122,7 @@ public class LocalDateTimeUtils { return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX); } + // TODO @puhui999:加下注释哈; public static Long between(LocalDateTime dateTime) { return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java index af0cb1c1a..56e01d729 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/contact/CrmContactController.java @@ -46,7 +46,7 @@ import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT; +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE; @Tag(name = "管理后台 - CRM 联系人") @RestController @@ -156,7 +156,7 @@ public class CrmContactController { public CommonResult> getCustomerOperateLog(@RequestParam("bizId")Long bizId) { OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO(); reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - reqVO.setBizType(CRM_CONTACT); + reqVO.setBizType(CRM_CONTACT_TYPE); reqVO.setBizId(bizId); return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class))); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java index dacbfa7ca..60903bd0a 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java @@ -112,37 +112,42 @@ public class CrmCustomerController { } // 2. 拼接数据 - // 距离进入公海的时间 - Map poolDayMap = getPoolDayMap(pageResult); + Map poolDayMap = getPoolDayMap(pageResult); // 距离进入公海的时间 Map userMap = adminUserApi.getUserMap( convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId()))); Map deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId)); return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap)); } + // TODO @puhui999:加下注释哈; private Map getPoolDayMap(PageResult pageResult) { Map poolDayMap = null; CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig(); + // TODO @puhui999:if return 减少括号 if (customerPoolConfig != null && customerPoolConfig.getEnabled()) { // 有公海配置的情况 + // TODO @puhui999:item 改成 customer 更好,容易理解; poolDayMap = convertMap(pageResult.getList(), CrmCustomerDO::getId, item -> { long dealExpireDay = 0; if (!item.getDealStatus()) { // 检查是否成交 dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(item.getCreateTime()); } + // TODO @puhui999:需要考虑 contactLastTime 为空的情况哈; long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(item.getContactLastTime()); return dealExpireDay == 0 ? contactExpireDay : Math.min(dealExpireDay, contactExpireDay); }); + // TODO @puhui999:需要考虑 lock 的情况么? } return poolDayMap; } @GetMapping(value = "/list-all-simple") @Operation(summary = "获取客户精简信息列表", description = "只包含有读权限的客户,主要用于前端的下拉选项") - public CommonResult> getSimpleDeptList() { + public CommonResult> getSimpleDeptList() { CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 List list = customerService.getCustomerPage(reqVO, getLoginUserId()).getList(); - return success(BeanUtils.toBean(list, CrmCustomerSimpleRespVO.class)); + return success(convertList(list, customer -> // 只返回 id、name 精简字段 + new CrmCustomerRespVO().setId(customer.getId()).setName(customer.getName()))); } @GetMapping("/export-excel") @@ -154,8 +159,8 @@ public class CrmCustomerController { pageVO.setPageSize(PAGE_SIZE_NONE); // 不分页 List list = customerService.getCustomerPage(pageVO, getLoginUserId()).getList(); // 导出 Excel - List datas = CrmCustomerConvert.INSTANCE.convertList02(list); - ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, datas); + ExcelUtils.write(response, "客户.xls", "数据", CrmCustomerRespVO.class, + BeanUtils.toBean(list, CrmCustomerRespVO.class)); } @PutMapping("/transfer") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerDistributeReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerDistributeReqVO.java index b8bd2acb6..fcb9ac57f 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerDistributeReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerDistributeReqVO.java @@ -11,7 +11,7 @@ import java.util.List; public class CrmCustomerDistributeReqVO { @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]") - @NotNull(message = "客户编号不能为空") + @NotNull(message = "客户编号不能为空") // TODO @puhui999:list 是 @NotEmpty private List ids; @Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerSimpleRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerSimpleRespVO.java deleted file mode 100644 index 22ba6ed4e..000000000 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerSimpleRespVO.java +++ /dev/null @@ -1,20 +0,0 @@ -package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; - -import io.swagger.v3.oas.annotations.media.Schema; -import lombok.AllArgsConstructor; -import lombok.Data; -import lombok.NoArgsConstructor; - -@Schema(description = "管理后台 - 客户精简信息 Response VO") -@Data -@NoArgsConstructor -@AllArgsConstructor -public class CrmCustomerSimpleRespVO { - - @Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - private Long id; - - @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋道") - private String name; - -} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java index 1501e854e..8ff03ad66 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigRespVO.java @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotNull; import lombok.Data; import java.time.LocalDateTime; @@ -17,7 +16,6 @@ public class CrmCustomerLimitConfigRespVO { private Long id; @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @NotNull(message = "规则类型不能为空") private Integer type; @Schema(description = "规则适用人群") @@ -27,10 +25,9 @@ public class CrmCustomerLimitConfigRespVO { private List deptIds; @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - @NotNull(message = "数量上限不能为空") private Integer maxCount; - @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") + @Schema(description = "成交客户是否占有拥有客户数") private Boolean dealCountEnabled; @Schema(description = "规则适用人群名称") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java index bd404c9e1..69ab5e628 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/limitconfig/CrmCustomerLimitConfigSaveReqVO.java @@ -15,10 +15,11 @@ public class CrmCustomerLimitConfigSaveReqVO { private Long id; @Schema(description = "规则类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") - @DiffLogField(name = "规则类型") @NotNull(message = "规则类型不能为空") + @DiffLogField(name = "规则类型") private Integer type; + // TODO @puhui999:可以把 Function 那的 functionName 搞成 NAME 枚举,这里直接引用。这样后续改动更方便哈。 @Schema(description = "规则适用人群") @DiffLogField(name = "规则适用人群", function = "getAdminUserById") private List userIds; @@ -28,8 +29,8 @@ public class CrmCustomerLimitConfigSaveReqVO { private List deptIds; @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") - @DiffLogField(name = "数量上限") @NotNull(message = "数量上限不能为空") + @DiffLogField(name = "数量上限") private Integer maxCount; @Schema(description = "成交客户是否占有拥有客户数(当 type = 1 时)") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java index 79855ee42..09636e4e7 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerConvert.java @@ -16,7 +16,6 @@ import org.mapstruct.Mapper; import org.mapstruct.Mapping; import org.mapstruct.factory.Mappers; -import java.util.List; import java.util.Map; import static cn.iocoder.yudao.framework.common.util.collection.MapUtils.findAndThen; @@ -31,6 +30,7 @@ public interface CrmCustomerConvert { CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class); + // TODO @puhui999:可以清理掉可以用 BeanUtil 替代的方法哈 CrmCustomerDO convert(CrmCustomerSaveReqVO bean); CrmCustomerRespVO convert(CrmCustomerDO bean); @@ -51,8 +51,6 @@ public interface CrmCustomerConvert { findAndThen(userMap, Long.parseLong(customer.getCreator()), user -> customer.setCreatorName(user.getNickname())); } - List convertList02(List list); - @Mapping(target = "bizId", source = "reqVO.id") CrmPermissionTransferReqBO convert(CrmCustomerTransferReqVO reqVO, Long userId); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java index 8508df6b2..913865bdb 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/customer/CrmCustomerLimitConfigConvert.java @@ -23,6 +23,7 @@ public interface CrmCustomerLimitConfigConvert { CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); + // TODO @puhui999:可以把 convert 改成 BeanUtils CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java index 1241eea14..5b81e67ad 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/convert/permission/CrmPermissionConvert.java @@ -48,9 +48,7 @@ public interface CrmPermissionConvert { return CollectionUtils.convertList(convert(permission), item -> { findAndThen(userMap, item.getUserId(), user -> { item.setNickname(user.getNickname()); - findAndThen(deptMap, user.getDeptId(), deptRespDTO -> { - item.setDeptName(deptRespDTO.getName()); - }); + findAndThen(deptMap, user.getDeptId(), deptRespDTO -> item.setDeptName(deptRespDTO.getName())); List postRespList = MapUtils.getList(Multimaps.forMap(postMap), user.getPostIds()); if (CollUtil.isEmpty(postRespList)) { item.setPostNames(Collections.emptySet()); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java index 03ce96fc3..14e7c71fe 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/permission/core/aop/CrmPermissionAspect.java @@ -40,12 +40,12 @@ public class CrmPermissionAspect { @Before("@annotation(crmPermission)") public void doBefore(JoinPoint joinPoint, CrmPermission crmPermission) { - // 获取相关属性值 + // 1.1 获取相关属性值 Map expressionValues = parseExpressions(joinPoint, crmPermission); Integer bizType = StrUtil.isEmpty(crmPermission.bizTypeValue()) ? crmPermission.bizType()[0].getType() : (Integer) expressionValues.get(crmPermission.bizTypeValue()); // 模块类型 - // 处理兼容多个 bizId 的情况 - Object object = expressionValues.get(crmPermission.bizId());// 模块数据编号 + // 1.2 处理兼容多个 bizId 的情况 + Object object = expressionValues.get(crmPermission.bizId()); // 模块数据编号 Set bizIds = new HashSet<>(); if (object instanceof Collection) { bizIds.addAll(convertSet((Collection) object, item -> Long.parseLong(item.toString()))); @@ -53,11 +53,11 @@ public class CrmPermissionAspect { bizIds.add(Long.parseLong(object.toString())); } Integer permissionLevel = crmPermission.level().getLevel(); // 需要的权限级别 + + // 2. 逐个校验权限 List permissionList = crmPermissionService.getPermissionListByBiz(bizType, bizIds); Map> multiMap = convertMultiMap(permissionList, CrmPermissionDO::getBizId); - bizIds.forEach(bizId -> { - validatePermission(bizType, multiMap.get(bizId), permissionLevel); - }); + bizIds.forEach(bizId -> validatePermission(bizType, multiMap.get(bizId), permissionLevel)); } private void validatePermission(Integer bizType, List bizPermissions, Integer permissionLevel) { @@ -71,7 +71,6 @@ public class CrmPermissionAspect { if (CrmPermissionLevelEnum.isRead(permissionLevel)) { return; } - // 没有数据权限的情况下超出了读权限直接报错,避免后面校验空指针 throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); } else { // 1.2 有数据权限但是没有负责人的情况 @@ -102,9 +101,8 @@ public class CrmPermissionAspect { } } } - // 2.4 没有权限! - // 打个 info 日志,方便后续排查问题、审计 - log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", + // 2.4 没有权限,抛出异常 + log.info("[doBefore][userId({}) 要求权限({}) 实际权限({}) 数据校验错误]", // 打个 info 日志,方便后续排查问题、审计 getUserId(), permissionLevel, toJsonString(userPermission)); throw exception(CRM_PERMISSION_DENIED, CrmBizTypeEnum.getNameByType(bizType)); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java index 136cc93a2..655190ab3 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/contact/CrmContactServiceImpl.java @@ -33,7 +33,7 @@ import java.util.List; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.*; -import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT; +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_CONTACT_TYPE; import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.USER_NOT_EXISTS; import static java.util.Collections.singletonList; @@ -65,7 +65,7 @@ public class CrmContactServiceImpl implements CrmContactService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT, subType = "创建联系人", bizNo = "{{#contactId}}", success = "创建了联系人[{{#contactName}}]") + @LogRecord(type = CRM_CONTACT_TYPE, subType = "创建联系人", bizNo = "{{#contactId}}", success = "创建了联系人[{{#contactName}}]") public Long createContact(CrmContactSaveReqVO createReqVO, Long userId) { // 1. 校验 validateRelationDataExists(createReqVO); @@ -93,7 +93,7 @@ public class CrmContactServiceImpl implements CrmContactService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CONTACT, subType = "更新联系人", bizNo = "{{#updateReqVO.id}}", success = "更新了联系人{_DIFF{#updateReqVO}}") + @LogRecord(type = CRM_CONTACT_TYPE, subType = "更新联系人", bizNo = "{{#updateReqVO.id}}", success = "更新了联系人{_DIFF{#updateReqVO}}") @CrmPermission(bizType = CrmBizTypeEnum.CRM_CONTACT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) public void updateContact(CrmContactSaveReqVO updateReqVO) { // 1. 校验存在 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java index 3e7a66f91..cc71bac0c 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerLimitConfigServiceImpl.java @@ -44,7 +44,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig private AdminUserApi adminUserApi; @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", + success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); // 插入 @@ -54,12 +55,12 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig // 记录操作日志上下文 LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(customerLimitConfig.getType())); LogRecordContext.putVariable("limitId", customerLimitConfig.getId()); - // 返回 return customerLimitConfig.getId(); } @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", + success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { // 校验存在 CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); @@ -73,7 +74,8 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig } @Override - @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", + success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) public void deleteCustomerLimitConfig(Long id) { // 校验存在 CrmCustomerLimitConfigDO limitConfigDO = validateCustomerLimitConfigExists(id); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java index 966d05b0d..2a0e5ade9 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerPoolConfigServiceImpl.java @@ -34,6 +34,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe */ @Override public CrmCustomerPoolConfigDO getCustomerPoolConfig() { + // TODO @puhui999:这个要搞到 mapper 里噢。 return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX().last("LIMIT 1")); } @@ -43,7 +44,8 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe * @param saveReqVO 更新信息 */ @Override - @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", + success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { // 存在,则进行更新 CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java index fc15e6f4f..a18f65d33 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java @@ -65,7 +65,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_CREATE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_CREATE_SUB_TYPE, bizNo = "{{#customer.id}}", + success = CRM_CUSTOMER_CREATE_SUCCESS) public Long createCustomer(CrmCustomerSaveReqVO createReqVO, Long userId) { createReqVO.setId(null); // 1. 校验拥有客户是否到达上限 @@ -89,12 +90,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_CUSTOMER_UPDATE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", + success = CRM_CUSTOMER_UPDATE_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) public void updateCustomer(CrmCustomerSaveReqVO updateReqVO) { Assert.notNull(updateReqVO.getId(), "客户编号不能为空"); - // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改。 - updateReqVO.setOwnerUserId(null); + updateReqVO.setOwnerUserId(null); // 更新的时候,要把 updateReqVO 负责人设置为空,避免修改 // 1. 校验存在 CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId()); @@ -109,7 +110,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_DELETE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_DELETE_SUB_TYPE, bizNo = "{{#id}}", + success = CRM_CUSTOMER_DELETE_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) public void deleteCustomer(Long id) { // 校验存在 @@ -128,7 +130,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", success = CRM_CUSTOMER_TRANSFER_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_TRANSFER_SUB_TYPE, bizNo = "{{#reqVO.id}}", + success = CRM_CUSTOMER_TRANSFER_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#reqVO.id", level = CrmPermissionLevelEnum.OWNER) public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { // 1.1 校验客户是否存在 @@ -144,11 +147,13 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { // 3. TODO 记录转移日志 // 记录操作日志上下文 + // TODO @puhui999:crmCustomer=》customer,也看看其他有没类似的情况哈 LogRecordContext.putVariable("crmCustomer", customer); } @Override - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", success = CRM_CUSTOMER_LOCK_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_LOCK_SUB_TYPE, bizNo = "{{#lockReqVO.id}}", + success = CRM_CUSTOMER_LOCK_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#lockReqVO.id", level = CrmPermissionLevelEnum.OWNER) public void lockCustomer(CrmCustomerLockReqVO lockReqVO, Long userId) { // 1.1 校验当前客户是否存在 @@ -165,7 +170,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { // 2. 更新锁定状态 customerMapper.updateById(BeanUtils.toBean(lockReqVO, CrmCustomerDO.class)); - // 3. 记录操作日志上下文. tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定 + // 3. 记录操作日志上下文 + // tips: 因为这里使用的是老的状态所以记录时反着记录,也就是 lockStatus 为 true 那么就是解锁反之为锁定 LogRecordContext.putVariable("crmCustomer", customer); } @@ -173,7 +179,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_POOL_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_POOL_SUB_TYPE, bizNo = "{{#id}}", + success = CRM_CUSTOMER_POOL_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) public void putCustomerPool(Long id) { // 1. 校验存在 @@ -252,7 +259,8 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { } } - @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_RECEIVE_SUCCESS) + @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", + success = CRM_CUSTOMER_RECEIVE_SUCCESS) public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { // 记录操作日志上下文 LogRecordContext.putVariable("customer", customer); @@ -280,7 +288,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { return customerMapper.selectPage(pageReqVO, userId); } - //======================= 校验相关 ======================= + // ======================= 校验相关 ======================= /** * 校验客户是否存在 diff --git a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java index 6a964204d..8f701d987 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/test/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImplTest.java @@ -138,38 +138,4 @@ public class CrmCustomerServiceImplTest extends BaseDbUnitTest { //assertPojoEquals(dbCustomer, pageResult.getList().get(0)); } - @Test - @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 - public void testGetCustomerList() { - // mock 数据 - CrmCustomerDO dbCustomer = randomPojo(CrmCustomerDO.class, o -> { // 等会查询到 - o.setName(null); - o.setMobile(null); - o.setTelephone(null); - o.setWebsite(null); - }); - customerMapper.insert(dbCustomer); - // 测试 name 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setName(null))); - // 测试 mobile 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setMobile(null))); - // 测试 telephone 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setTelephone(null))); - // 测试 website 不匹配 - customerMapper.insert(cloneIgnoreId(dbCustomer, o -> o.setWebsite(null))); - // 准备参数 - CrmCustomerPageReqVO reqVO = new CrmCustomerPageReqVO(); - reqVO.setName("张三"); - reqVO.setMobile("13888888888"); - reqVO.setPageSize(PAGE_SIZE_NONE); - //reqVO.setTelephone(null); - //reqVO.setWebsite(null); - - // 调用 - PageResult pageResult = customerService.getCustomerPage(reqVO, 1L); - // 断言 - assertEquals(1, pageResult.getList().size()); - assertPojoEquals(dbCustomer, pageResult.getList().get(0)); - } - } diff --git a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java index 970630b10..c43021b93 100644 --- a/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java +++ b/yudao-module-mp/yudao-module-mp-biz/src/main/java/cn/iocoder/yudao/module/mp/service/message/MpMessageServiceImpl.java @@ -74,6 +74,7 @@ public class MpMessageServiceImpl implements MpMessageService { Assert.notNull(account, "公众号账号({}) 不存在", appId); // 订阅事件不记录,因为此时公众号粉丝表中还没有此粉丝的数据 + // TODO @芋艿:这个修复,后续看看还有啥问题 if (ObjUtil.equal(wxMessage.getEvent(), WxConsts.EventType.SUBSCRIBE)) { return; }