Commit a1c17b9b00a996a85e53b0e47aad37821dee7e80
1 parent
d8bb55fc
CRM-客户:日志表达式调整
Showing
5 changed files
with
47 additions
and
17 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
| @@ -18,17 +18,17 @@ public interface LogRecordConstants { | @@ -18,17 +18,17 @@ public interface LogRecordConstants { | ||
| 18 | String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户"; | 18 | String CRM_CUSTOMER_CREATE_SUB_TYPE = "创建客户"; |
| 19 | String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}"; | 19 | String CRM_CUSTOMER_CREATE_SUCCESS = "创建了客户{{#customer.name}}"; |
| 20 | String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户"; | 20 | String CRM_CUSTOMER_UPDATE_SUB_TYPE = "更新客户"; |
| 21 | - String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】{_DIFF{#updateReqVO}}"; | 21 | + String CRM_CUSTOMER_UPDATE_SUCCESS = "更新了客户【{{#customerName}}】: {_DIFF{#updateReqVO}}"; |
| 22 | String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户"; | 22 | String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户"; |
| 23 | String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】"; | 23 | String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】"; |
| 24 | String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户"; | 24 | String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户"; |
| 25 | String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; | 25 | String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; |
| 26 | String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#crmCustomer.lockStatus ? '锁定客户' : '解锁客户'}}"; | 26 | String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#crmCustomer.lockStatus ? '锁定客户' : '解锁客户'}}"; |
| 27 | - String CRM_CUSTOMER_LOCK_SUCCESS = "{{#crmCustomer.lockStatus ? '将客户【#crmCustomer.name】锁定' : '将客户【#crmCustomer.name】解锁'}}"; | 27 | + String CRM_CUSTOMER_LOCK_SUCCESS = "{{#crmCustomer.lockStatus ? '将客户【' + #crmCustomer.name + '】锁定' : '将客户【' + #crmCustomer.name + '】解锁'}}"; |
| 28 | String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海"; | 28 | String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海"; |
| 29 | String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海"; | 29 | String CRM_CUSTOMER_POOL_SUCCESS = "将客户【{{#customerName}}】放入了公海"; |
| 30 | String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; | 30 | String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; |
| 31 | - String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【#customer.name】分配给【#ownerUserName】' : '领取客户【#customer.name】'}}"; | 31 | + String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}"; |
| 32 | 32 | ||
| 33 | // ======================= CRM_CONTACT 联系人 ======================= | 33 | // ======================= CRM_CONTACT 联系人 ======================= |
| 34 | 34 |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/poolconfig/CrmCustomerPoolConfigSaveReqVO.java
| 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | 1 | package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.BooleanUtil; | 3 | import cn.hutool.core.util.BooleanUtil; |
| 4 | -import cn.hutool.core.util.ObjectUtil; | 4 | +import com.fasterxml.jackson.annotation.JsonIgnore; |
| 5 | import io.swagger.v3.oas.annotations.media.Schema; | 5 | import io.swagger.v3.oas.annotations.media.Schema; |
| 6 | +import jakarta.validation.constraints.AssertTrue; | ||
| 6 | import lombok.Data; | 7 | import lombok.Data; |
| 7 | import lombok.EqualsAndHashCode; | 8 | import lombok.EqualsAndHashCode; |
| 8 | import lombok.ToString; | 9 | import lombok.ToString; |
| 9 | 10 | ||
| 10 | -import jakarta.validation.constraints.AssertTrue; | ||
| 11 | import java.util.Objects; | 11 | import java.util.Objects; |
| 12 | 12 | ||
| 13 | @Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO") | 13 | @Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO") |
| @@ -16,19 +16,27 @@ import java.util.Objects; | @@ -16,19 +16,27 @@ import java.util.Objects; | ||
| 16 | @ToString(callSuper = true) | 16 | @ToString(callSuper = true) |
| 17 | public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO { | 17 | public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO { |
| 18 | 18 | ||
| 19 | - // TODO @puhui999:AssertTrue 必须 is 开头哈;注意需要 json 忽略下,避免被序列化; | ||
| 20 | - @AssertTrue(message = "客户公海规则设置不正确") | ||
| 21 | - // TODO @puhui999:这个方法,是不是拆成 2 个,一个校验 contactExpireDays、一个校验 dealExpireDays; | ||
| 22 | - public boolean poolEnableValid() { | 19 | + @AssertTrue(message = "未成交放入公海天数不能为空") |
| 20 | + @JsonIgnore | ||
| 21 | + public boolean isDealExpireDaysValid() { | ||
| 22 | + if (!BooleanUtil.isTrue(getEnabled())) { | ||
| 23 | + return true; | ||
| 24 | + } | ||
| 25 | + return Objects.nonNull(getDealExpireDays()); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @AssertTrue(message = "未跟进放入公海天数不能为空") | ||
| 29 | + @JsonIgnore | ||
| 30 | + public boolean isContactExpireDaysValid() { | ||
| 23 | if (!BooleanUtil.isTrue(getEnabled())) { | 31 | if (!BooleanUtil.isTrue(getEnabled())) { |
| 24 | return true; | 32 | return true; |
| 25 | } | 33 | } |
| 26 | - return ObjectUtil.isAllNotEmpty(getContactExpireDays(), getDealExpireDays()); | 34 | + return Objects.nonNull(getContactExpireDays()); |
| 27 | } | 35 | } |
| 28 | 36 | ||
| 29 | - @AssertTrue(message = "客户公海规则设置不正确") | ||
| 30 | - // TODO @puhui999:这个方法,是不是改成 isNotifyDaysValid() 更好点?本质校验的是 notifyDays 是否为空 | ||
| 31 | - public boolean notifyEnableValid() { | 37 | + @AssertTrue(message = "提前提醒天数不能为空") |
| 38 | + @JsonIgnore | ||
| 39 | + public boolean isNotifyDaysValid() { | ||
| 32 | if (!BooleanUtil.isTrue(getNotifyEnabled())) { | 40 | if (!BooleanUtil.isTrue(getNotifyEnabled())) { |
| 33 | return true; | 41 | return true; |
| 34 | } | 42 | } |
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/customer/CrmCustomerServiceImpl.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.customer; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.service.customer; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.lang.Assert; | 4 | import cn.hutool.core.lang.Assert; |
| 5 | +import cn.hutool.extra.spring.SpringUtil; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| @@ -247,13 +248,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -247,13 +248,15 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 247 | user = adminUserApi.getUser(ownerUserId); | 248 | user = adminUserApi.getUser(ownerUserId); |
| 248 | } | 249 | } |
| 249 | for (CrmCustomerDO customer : customers) { | 250 | for (CrmCustomerDO customer : customers) { |
| 250 | - receiveCustomerLog(customer, user == null ? null : user.getNickname()); | 251 | + getSelf().receiveCustomerLog(customer, user == null ? null : user.getNickname()); |
| 251 | } | 252 | } |
| 252 | } | 253 | } |
| 253 | 254 | ||
| 254 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_RECEIVE_SUCCESS) | 255 | @LogRecord(type = CRM_CUSTOMER_TYPE, subType = CRM_CUSTOMER_RECEIVE_SUB_TYPE, bizNo = "{{#customer.id}}", success = CRM_CUSTOMER_RECEIVE_SUCCESS) |
| 255 | public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { | 256 | public void receiveCustomerLog(CrmCustomerDO customer, String ownerUserName) { |
| 256 | - | 257 | + // 记录操作日志上下文 |
| 258 | + LogRecordContext.putVariable("customer", customer); | ||
| 259 | + LogRecordContext.putVariable("ownerUserName", ownerUserName); | ||
| 257 | } | 260 | } |
| 258 | 261 | ||
| 259 | //======================= 查询相关 ======================= | 262 | //======================= 查询相关 ======================= |
| @@ -364,4 +367,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | @@ -364,4 +367,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { | ||
| 364 | } | 367 | } |
| 365 | } | 368 | } |
| 366 | 369 | ||
| 370 | + | ||
| 371 | + /** | ||
| 372 | + * 获得自身的代理对象,解决 AOP 生效问题 | ||
| 373 | + * | ||
| 374 | + * @return 自己 | ||
| 375 | + */ | ||
| 376 | + private CrmCustomerServiceImpl getSelf() { | ||
| 377 | + return SpringUtil.getBean(getClass()); | ||
| 378 | + } | ||
| 379 | + | ||
| 367 | } | 380 | } |
yudao-module-system/yudao-module-system-api/src/main/java/cn/iocoder/yudao/module/system/api/logger/dto/OperateLogV2RespDTO.java
| @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.system.api.logger.dto; | @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.system.api.logger.dto; | ||
| 2 | 2 | ||
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | 4 | ||
| 5 | +import java.time.LocalDateTime; | ||
| 6 | + | ||
| 5 | /** | 7 | /** |
| 6 | * 系统操作日志 Resp DTO | 8 | * 系统操作日志 Resp DTO |
| 7 | * | 9 | * |
| @@ -64,4 +66,9 @@ public class OperateLogV2RespDTO { | @@ -64,4 +66,9 @@ public class OperateLogV2RespDTO { | ||
| 64 | */ | 66 | */ |
| 65 | private String userAgent; | 67 | private String userAgent; |
| 66 | 68 | ||
| 69 | + /** | ||
| 70 | + * 创建时间 | ||
| 71 | + */ | ||
| 72 | + private LocalDateTime createTime; | ||
| 73 | + | ||
| 67 | } | 74 | } |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/convert/logger/OperateLogConvert.java
| @@ -35,10 +35,12 @@ public interface OperateLogConvert { | @@ -35,10 +35,12 @@ public interface OperateLogConvert { | ||
| 35 | return BeanUtils.toBean(operateLogPage, OperateLogV2RespDTO.class).setList(setUserInfo(operateLogPage.getList(), userList)); | 35 | return BeanUtils.toBean(operateLogPage, OperateLogV2RespDTO.class).setList(setUserInfo(operateLogPage.getList(), userList)); |
| 36 | } | 36 | } |
| 37 | 37 | ||
| 38 | - private static List<OperateLogV2RespDTO> setUserInfo(List<OperateLogV2DO> logList, List<AdminUserDO> userList) { | 38 | + OperateLogV2RespDTO convert(OperateLogV2DO operateLogV2DO); |
| 39 | + | ||
| 40 | + private List<OperateLogV2RespDTO> setUserInfo(List<OperateLogV2DO> logList, List<AdminUserDO> userList) { | ||
| 39 | Map<Long, AdminUserDO> userMap = convertMap(userList, AdminUserDO::getId); | 41 | Map<Long, AdminUserDO> userMap = convertMap(userList, AdminUserDO::getId); |
| 40 | return CollectionUtils.convertList(logList, item -> { | 42 | return CollectionUtils.convertList(logList, item -> { |
| 41 | - OperateLogV2RespDTO respDTO = BeanUtils.toBean(item, OperateLogV2RespDTO.class); | 43 | + OperateLogV2RespDTO respDTO = convert(item); |
| 42 | findAndThen(userMap, item.getUserId(), user -> respDTO.setUserName(user.getNickname())); | 44 | findAndThen(userMap, item.getUserId(), user -> respDTO.setUserName(user.getNickname())); |
| 43 | return respDTO; | 45 | return respDTO; |
| 44 | }); | 46 | }); |