Commit 3c74b22933cd84bcf2c62293d76a823af29a100b

Authored by puhui999
1 parent c74881c8

系统操作日志:集成 mzt-biz-log 4

Showing 12 changed files with 224 additions and 17 deletions
yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
@@ -20,8 +20,7 @@ public interface LogRecordConstants { @@ -20,8 +20,7 @@ public interface LogRecordConstants {
20 20
21 //======================= 客户转移操作日志 ======================= 21 //======================= 客户转移操作日志 =======================
22 22
23 - String TRANSFER_CUSTOMER_LOG_SUCCESS = "把客户【{{#crmCustomer == null ? '' : #crmCustomer.name}}】负责人从" +  
24 - "【{getAdminUserById{#crmCustomer == null ? '' : #crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】"; 23 + String TRANSFER_CUSTOMER_LOG_SUCCESS = "把客户【{{#crmCustomer.name}}】的负责人从【{getAdminUserById{#crmCustomer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
25 String TRANSFER_CUSTOMER_LOG_FAIL = ""; 24 String TRANSFER_CUSTOMER_LOG_FAIL = "";
26 25
27 } 26 }
yudao-module-crm/yudao-module-crm-biz/pom.xml
@@ -60,6 +60,10 @@ @@ -60,6 +60,10 @@
60 <groupId>cn.iocoder.boot</groupId> 60 <groupId>cn.iocoder.boot</groupId>
61 <artifactId>yudao-spring-boot-starter-excel</artifactId> 61 <artifactId>yudao-spring-boot-starter-excel</artifactId>
62 </dependency> 62 </dependency>
  63 + <dependency>
  64 + <groupId>cn.iocoder.boot</groupId>
  65 + <artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
  66 + </dependency>
63 67
64 <!-- Test 测试相关 --> 68 <!-- Test 测试相关 -->
65 <dependency> 69 <dependency>
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.http
@@ -9,4 +9,8 @@ tenant-id: {{adminTenentId}} @@ -9,4 +9,8 @@ tenant-id: {{adminTenentId}}
9 "newOwnerUserId": 127 9 "newOwnerUserId": 127
10 } 10 }
11 11
  12 +### 自定义日志记录结果
  13 +### 操作日志 ===> OperateLogV2CreateReqBO(traceId=, userId=1, userType=2, module=CRM-客户, name=客户转移, bizId=10, content=把客户【张三】的负责人从【芋道源码(15612345678)】变更为了【tttt】, requestMethod=PUT, requestUrl=/admin-api/crm/customer/transfer, userIp=127.0.0.1, userAgent=Apache-HttpClient/4.5.14 (Java/17.0.9))
12 14
  15 +### diff 日志
  16 +### | 操作日志 ===> OperateLogV2CreateReqBO(traceId=, userId=1, userType=2, module=CRM-客户, name=更新客户, bizId=11, content=更新了客户【所属行业】从【H 住宿和餐饮业】修改为【D 电力、热力、燃气及水生产和供应业】;【客户等级】从【C (非优先客户)】修改为【A (重点客户)】;【客户来源】从【线上咨询】修改为【预约上门】, requestMethod=PUT, requestUrl=/admin-api/crm/customer/update, userIp=0:0:0:0:0:0:0:1, userAgent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36)
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/CrmCustomerController.java
@@ -59,7 +59,7 @@ public class CrmCustomerController { @@ -59,7 +59,7 @@ public class CrmCustomerController {
59 } 59 }
60 60
61 @PutMapping("/update") 61 @PutMapping("/update")
62 - @Operation(summary = "更新客户") 62 + //@Operation(summary = "更新客户")
63 @PreAuthorize("@ss.hasPermission('crm:customer:update')") 63 @PreAuthorize("@ss.hasPermission('crm:customer:update')")
64 public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) { 64 public CommonResult<Boolean> updateCustomer(@Valid @RequestBody CrmCustomerUpdateReqVO updateReqVO) {
65 customerService.updateCustomer(updateReqVO); 65 customerService.updateCustomer(updateReqVO);
@@ -123,6 +123,7 @@ public class CrmCustomerController { @@ -123,6 +123,7 @@ public class CrmCustomerController {
123 } 123 }
124 124
125 @PutMapping("/transfer") 125 @PutMapping("/transfer")
  126 + //@Operation(summary = "客户转移")
126 @PreAuthorize("@ss.hasPermission('crm:customer:update')") 127 @PreAuthorize("@ss.hasPermission('crm:customer:update')")
127 public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) { 128 public CommonResult<Boolean> transfer(@Valid @RequestBody CrmCustomerTransferReqVO reqVO) {
128 customerService.transferCustomer(reqVO, getLoginUserId()); 129 customerService.transferCustomer(reqVO, getLoginUserId());
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/customer/vo/CrmCustomerBaseVO.java
@@ -3,17 +3,20 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo; @@ -3,17 +3,20 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
3 import cn.iocoder.yudao.framework.common.validation.InEnum; 3 import cn.iocoder.yudao.framework.common.validation.InEnum;
4 import cn.iocoder.yudao.framework.common.validation.Mobile; 4 import cn.iocoder.yudao.framework.common.validation.Mobile;
5 import cn.iocoder.yudao.framework.common.validation.Telephone; 5 import cn.iocoder.yudao.framework.common.validation.Telephone;
  6 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
6 import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; 7 import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum;
  8 +import com.mzt.logapi.starter.annotation.DiffLogField;
7 import io.swagger.v3.oas.annotations.media.Schema; 9 import io.swagger.v3.oas.annotations.media.Schema;
8 -import lombok.Data;  
9 -import org.springframework.format.annotation.DateTimeFormat;  
10 -  
11 import jakarta.validation.constraints.Email; 10 import jakarta.validation.constraints.Email;
12 import jakarta.validation.constraints.NotEmpty; 11 import jakarta.validation.constraints.NotEmpty;
13 import jakarta.validation.constraints.Size; 12 import jakarta.validation.constraints.Size;
  13 +import lombok.Data;
  14 +import org.springframework.format.annotation.DateTimeFormat;
  15 +
14 import java.time.LocalDateTime; 16 import java.time.LocalDateTime;
15 17
16 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; 18 import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  19 +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
17 20
18 /** 21 /**
19 * 客户 Base VO,提供给添加、修改、详细的子 VO 使用 22 * 客户 Base VO,提供给添加、修改、详细的子 VO 使用
@@ -23,57 +26,73 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @@ -23,57 +26,73 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
23 public class CrmCustomerBaseVO { 26 public class CrmCustomerBaseVO {
24 27
25 @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") 28 @Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
  29 + @DiffLogField(name = "客户名称")
26 @NotEmpty(message = "客户名称不能为空") 30 @NotEmpty(message = "客户名称不能为空")
27 private String name; 31 private String name;
28 32
29 @Schema(description = "所属行业", example = "1") 33 @Schema(description = "所属行业", example = "1")
  34 + @DiffLogField(name = "所属行业", function = "getIndustryById")
  35 + @DictFormat(CRM_CUSTOMER_INDUSTRY)
30 private Integer industryId; 36 private Integer industryId;
31 37
32 @Schema(description = "客户等级", example = "2") 38 @Schema(description = "客户等级", example = "2")
  39 + @DiffLogField(name = "客户等级", function = "getLevel")
33 @InEnum(CrmCustomerLevelEnum.class) 40 @InEnum(CrmCustomerLevelEnum.class)
34 private Integer level; 41 private Integer level;
35 42
36 @Schema(description = "客户来源", example = "3") 43 @Schema(description = "客户来源", example = "3")
  44 + @DiffLogField(name = "客户来源", function = "getSource")
37 private Integer source; 45 private Integer source;
38 46
39 @Schema(description = "手机", example = "18000000000") 47 @Schema(description = "手机", example = "18000000000")
  48 + @DiffLogField(name = "手机")
40 @Mobile 49 @Mobile
41 private String mobile; 50 private String mobile;
42 51
43 @Schema(description = "电话", example = "18000000000") 52 @Schema(description = "电话", example = "18000000000")
  53 + @DiffLogField(name = "电话")
44 @Telephone 54 @Telephone
45 private String telephone; 55 private String telephone;
46 56
47 @Schema(description = "网址", example = "https://www.baidu.com") 57 @Schema(description = "网址", example = "https://www.baidu.com")
  58 + @DiffLogField(name = "网址")
48 private String website; 59 private String website;
49 60
50 @Schema(description = "QQ", example = "123456789") 61 @Schema(description = "QQ", example = "123456789")
  62 + @DiffLogField(name = "QQ")
51 @Size(max = 20, message = "QQ长度不能超过 20 个字符") 63 @Size(max = 20, message = "QQ长度不能超过 20 个字符")
52 private String qq; 64 private String qq;
53 65
54 - @Schema(description = "wechat", example = "123456789") 66 + @Schema(description = "微信", example = "123456789")
  67 + @DiffLogField(name = "微信")
55 @Size(max = 255, message = "微信长度不能超过 255 个字符") 68 @Size(max = 255, message = "微信长度不能超过 255 个字符")
56 private String wechat; 69 private String wechat;
57 70
58 - @Schema(description = "email", example = "123456789@qq.com") 71 + @Schema(description = "邮箱", example = "123456789@qq.com")
  72 + @DiffLogField(name = "邮箱")
59 @Email(message = "邮箱格式不正确") 73 @Email(message = "邮箱格式不正确")
60 @Size(max = 255, message = "邮箱长度不能超过 255 个字符") 74 @Size(max = 255, message = "邮箱长度不能超过 255 个字符")
61 private String email; 75 private String email;
62 76
63 @Schema(description = "客户描述", example = "任意文字") 77 @Schema(description = "客户描述", example = "任意文字")
  78 + @DiffLogField(name = "客户描述")
64 @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符") 79 @Size(max = 4096, message = "客户描述长度不能超过 4096 个字符")
65 private String description; 80 private String description;
66 81
67 @Schema(description = "备注", example = "随便") 82 @Schema(description = "备注", example = "随便")
  83 + @DiffLogField(name = "备注")
68 private String remark; 84 private String remark;
69 85
70 @Schema(description = "地区编号", example = "20158") 86 @Schema(description = "地区编号", example = "20158")
  87 + @DiffLogField(name = "地区编号", function = "getAreaById")
71 private Integer areaId; 88 private Integer areaId;
72 89
73 @Schema(description = "详细地址", example = "北京市海淀区") 90 @Schema(description = "详细地址", example = "北京市海淀区")
  91 + @DiffLogField(name = "详细地址")
74 private String detailAddress; 92 private String detailAddress;
75 93
76 @Schema(description = "下次联系时间") 94 @Schema(description = "下次联系时间")
  95 + @DiffLogField(name = "下次联系时间")
77 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 96 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
78 private LocalDateTime contactNextTime; 97 private LocalDateTime contactNextTime;
79 98
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/function/CrmIndustryParseFunction.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.framework.bizlog.function;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
  5 +import com.mzt.logapi.service.IParseFunction;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
  10 +
  11 +/**
  12 + * 自定义函数-通过行业编号获取行业信息
  13 + *
  14 + * @author HUIHUI
  15 + */
  16 +@Slf4j
  17 +@Component
  18 +public class CrmIndustryParseFunction implements IParseFunction {
  19 +
  20 + @Override
  21 + public boolean executeBefore() {
  22 + return true; // 先转换值后对比
  23 + }
  24 +
  25 + @Override
  26 + public String functionName() {
  27 + return "getIndustryById";
  28 + }
  29 +
  30 + @Override
  31 + public String apply(Object value) {
  32 + if (value == null) {
  33 + return "";
  34 + }
  35 + if (StrUtil.isEmpty(value.toString())) {
  36 + return "";
  37 + }
  38 +
  39 + // 获取行业信息
  40 + try {
  41 + return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_INDUSTRY, value.toString());
  42 + } catch (Exception ignored) {
  43 + }
  44 + return "";
  45 + }
  46 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/function/CrmLevelParseFunction.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.framework.bizlog.function;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
  5 +import com.mzt.logapi.service.IParseFunction;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL;
  10 +
  11 +/**
  12 + * 自定义函数-通过客户等级编号获取客户等级信息
  13 + *
  14 + * @author HUIHUI
  15 + */
  16 +@Slf4j
  17 +@Component
  18 +public class CrmLevelParseFunction implements IParseFunction {
  19 +
  20 + @Override
  21 + public boolean executeBefore() {
  22 + return true; // 先转换值后对比
  23 + }
  24 +
  25 + @Override
  26 + public String functionName() {
  27 + return "getLevel";
  28 + }
  29 +
  30 + @Override
  31 + public String apply(Object value) {
  32 + if (value == null) {
  33 + return "";
  34 + }
  35 + if (StrUtil.isEmpty(value.toString())) {
  36 + return "";
  37 + }
  38 +
  39 + // 获取客户等级信息
  40 + try {
  41 + return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_LEVEL, value.toString());
  42 + } catch (Exception ignored) {
  43 + }
  44 + return "";
  45 + }
  46 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/function/CrmSourceParseFunction.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.framework.bizlog.function;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
  5 +import com.mzt.logapi.service.IParseFunction;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE;
  10 +
  11 +/**
  12 + * 自定义函数-通过客户来源编号获取客户来源信息
  13 + *
  14 + * @author HUIHUI
  15 + */
  16 +@Slf4j
  17 +@Component
  18 +public class CrmSourceParseFunction implements IParseFunction {
  19 +
  20 + @Override
  21 + public boolean executeBefore() {
  22 + return true; // 先转换值后对比
  23 + }
  24 +
  25 + @Override
  26 + public String functionName() {
  27 + return "getSource";
  28 + }
  29 +
  30 + @Override
  31 + public String apply(Object value) {
  32 + if (value == null) {
  33 + return "";
  34 + }
  35 + if (StrUtil.isEmpty(value.toString())) {
  36 + return "";
  37 + }
  38 +
  39 + // 获取客户来源信息
  40 + try {
  41 + return DictFrameworkUtils.getDictDataLabel(CRM_CUSTOMER_SOURCE, value.toString());
  42 + } catch (Exception ignored) {
  43 + }
  44 + return "";
  45 + }
  46 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/bizlog/package-info.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.framework.bizlog;
0 \ No newline at end of file 2 \ No newline at end of file
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.iocoder.yudao.framework.common.pojo.PageResult; 4 import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO; 6 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerCreateReqVO;
6 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO; 7 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerPageReqVO;
7 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO; 8 import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
@@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; @@ -16,6 +17,7 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
16 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 17 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
17 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 18 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
18 import com.mzt.logapi.context.LogRecordContext; 19 import com.mzt.logapi.context.LogRecordContext;
  20 +import com.mzt.logapi.service.impl.DiffParseFunction;
19 import com.mzt.logapi.starter.annotation.LogRecord; 21 import com.mzt.logapi.starter.annotation.LogRecord;
20 import jakarta.annotation.Resource; 22 import jakarta.annotation.Resource;
21 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
@@ -63,11 +65,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -63,11 +65,14 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
63 65
64 @Override 66 @Override
65 @Transactional(rollbackFor = Exception.class) 67 @Transactional(rollbackFor = Exception.class)
  68 + @LogRecord(success = "更新了客户{_DIFF{#updateReqVO}}", type = CRM_CUSTOMER, subType = "更新客户", bizNo = "{{#updateReqVO.id}}")
66 @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) 69 @CrmPermission(bizType = CrmBizTypeEnum.CRM_CUSTOMER, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)
67 public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) { 70 public void updateCustomer(CrmCustomerUpdateReqVO updateReqVO) {
68 // 校验存在 71 // 校验存在
69 - validateCustomerExists(updateReqVO.getId()); 72 + CrmCustomerDO oldCustomerDO = validateCustomerExists(updateReqVO.getId());
70 73
  74 + // __DIFF 函数传递了一个参数,传递的参数是修改之后的对象,这种方式需要在方法内部向 LogRecordContext 中 put 一个变量,代表是之前的对象,这个对象可以是null
  75 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldCustomerDO, CrmCustomerUpdateReqVO.class));
71 // 更新 76 // 更新
72 CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO); 77 CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO);
73 customerMapper.updateById(updateObj); 78 customerMapper.updateById(updateObj);
@@ -86,10 +91,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -86,10 +91,12 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
86 crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id); 91 crmPermissionService.deletePermission(CrmBizTypeEnum.CRM_CUSTOMER.getType(), id);
87 } 92 }
88 93
89 - private void validateCustomerExists(Long id) {  
90 - if (customerMapper.selectById(id) == null) { 94 + private CrmCustomerDO validateCustomerExists(Long id) {
  95 + CrmCustomerDO customerDO = customerMapper.selectById(id);
  96 + if (customerDO == null) {
91 throw exception(CUSTOMER_NOT_EXISTS); 97 throw exception(CUSTOMER_NOT_EXISTS);
92 } 98 }
  99 + return customerDO;
93 } 100 }
94 101
95 @Override 102 @Override
@@ -135,7 +142,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService { @@ -135,7 +142,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
135 public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) { 142 public void transferCustomer(CrmCustomerTransferReqVO reqVO, Long userId) {
136 // 1. 校验客户是否存在 143 // 1. 校验客户是否存在
137 validateCustomer(reqVO.getId()); 144 validateCustomer(reqVO.getId());
138 - // 添加 crmCustomer 到日志上下文 145 + // 添加 crmCustomer 到日志上下文 TODO 日志记录放在 service 里是因为已经过了权限校验查询时不用走两次校验
139 LogRecordContext.putVariable("crmCustomer", customerMapper.selectById(reqVO.getId())); 146 LogRecordContext.putVariable("crmCustomer", customerMapper.selectById(reqVO.getId()));
140 // 2.1 数据权限转移 147 // 2.1 数据权限转移
141 crmPermissionService.transferPermission( 148 crmPermissionService.transferPermission(
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/function/AdminUserParseFunction.java
@@ -22,11 +22,6 @@ public class AdminUserParseFunction implements IParseFunction { @@ -22,11 +22,6 @@ public class AdminUserParseFunction implements IParseFunction {
22 private AdminUserApi adminUserApi; 22 private AdminUserApi adminUserApi;
23 23
24 @Override 24 @Override
25 - public boolean executeBefore() {  
26 - return true;  
27 - }  
28 -  
29 - @Override  
30 public String functionName() { 25 public String functionName() {
31 return "getAdminUserById"; 26 return "getAdminUserById";
32 } 27 }
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/framework/bizlog/function/AreaParseFunction.java 0 → 100644
  1 +package cn.iocoder.yudao.module.system.framework.bizlog.function;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
  5 +import com.mzt.logapi.service.IParseFunction;
  6 +import lombok.extern.slf4j.Slf4j;
  7 +import org.springframework.stereotype.Component;
  8 +
  9 +/**
  10 + * 自定义函数-通过区域编号获取区域信息
  11 + *
  12 + * @author HUIHUI
  13 + */
  14 +@Slf4j
  15 +@Component
  16 +public class AreaParseFunction implements IParseFunction {
  17 +
  18 + @Override
  19 + public boolean executeBefore() {
  20 + return true; // 先转换值后对比
  21 + }
  22 +
  23 + @Override
  24 + public String functionName() {
  25 + return "getAreaById";
  26 + }
  27 +
  28 + @Override
  29 + public String apply(Object value) {
  30 + if (value == null) {
  31 + return "";
  32 + }
  33 + if (StrUtil.isEmpty(value.toString())) {
  34 + return "";
  35 + }
  36 +
  37 + return AreaUtils.format(Integer.parseInt(value.toString()));
  38 + }
  39 +}