Commit 803816b162b202e0c2200a00b0549f11f59ae75b

Authored by anhaohao
1 parent 722b3351

修改:CRM 产品分类和产品,优化了操作日志

yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java
@@ -60,7 +60,6 @@ public interface LogRecordConstants { @@ -60,7 +60,6 @@ public interface LogRecordConstants {
60 60
61 // ======================= CRM_PRODUCT 产品 ======================= 61 // ======================= CRM_PRODUCT 产品 =======================
62 62
63 - // TODO @hao:可以把 CRM 产品、和 CRM 产品分类分开哈,量程两个 type;  
64 String CRM_PRODUCT_TYPE = "CRM 产品"; 63 String CRM_PRODUCT_TYPE = "CRM 产品";
65 String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品"; 64 String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品";
66 String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】"; 65 String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】";
@@ -68,6 +67,9 @@ public interface LogRecordConstants { @@ -68,6 +67,9 @@ public interface LogRecordConstants {
68 String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}"; 67 String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}";
69 String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品"; 68 String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品";
70 String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】"; 69 String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】";
  70 +
  71 + // ======================= CRM_PRODUCT_CATEGORY 产品分类 =======================
  72 +
71 String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类"; 73 String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类";
72 String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类"; 74 String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类";
73 String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】"; 75 String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】";
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; 1 package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category;
2 2
  3 +import com.mzt.logapi.starter.annotation.DiffLogField;
3 import lombok.*; 4 import lombok.*;
4 import io.swagger.v3.oas.annotations.media.Schema; 5 import io.swagger.v3.oas.annotations.media.Schema;
5 6
@@ -14,6 +15,7 @@ public class CrmProductCategoryCreateReqVO{ @@ -14,6 +15,7 @@ public class CrmProductCategoryCreateReqVO{
14 15
15 @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") 16 @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
16 @NotNull(message = "分类名称不能为空") 17 @NotNull(message = "分类名称不能为空")
  18 + @DiffLogField(name = "分类名称")
17 private String name; 19 private String name;
18 20
19 @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") 21 @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java
1 package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; 1 package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product;
2 2
3 -import lombok.*; 3 +import com.mzt.logapi.starter.annotation.DiffLogField;
4 import io.swagger.v3.oas.annotations.media.Schema; 4 import io.swagger.v3.oas.annotations.media.Schema;
5 -  
6 import jakarta.validation.constraints.NotNull; 5 import jakarta.validation.constraints.NotNull;
  6 +import lombok.Data;
7 7
8 @Schema(description = "管理后台 - CRM 产品创建/修改 Request VO") 8 @Schema(description = "管理后台 - CRM 产品创建/修改 Request VO")
9 @Data 9 @Data
@@ -14,28 +14,35 @@ public class CrmProductSaveReqVO { @@ -14,28 +14,35 @@ public class CrmProductSaveReqVO {
14 14
15 @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") 15 @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品")
16 @NotNull(message = "产品名称不能为空") 16 @NotNull(message = "产品名称不能为空")
  17 + @DiffLogField(name = "产品名称")
17 private String name; 18 private String name;
18 19
19 @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") 20 @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306")
20 @NotNull(message = "产品编码不能为空") 21 @NotNull(message = "产品编码不能为空")
  22 + @DiffLogField(name = "产品编码")
21 private String no; 23 private String no;
22 24
23 @Schema(description = "单位", example = "2") 25 @Schema(description = "单位", example = "2")
  26 + @DiffLogField(name = "单位", function = "getProductUnitName")
24 private Integer unit; 27 private Integer unit;
25 28
26 @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") 29 @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911")
27 @NotNull(message = "价格不能为空") 30 @NotNull(message = "价格不能为空")
  31 + @DiffLogField(name = "价格")
28 private Long price; 32 private Long price;
29 33
30 @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") 34 @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架")
31 @NotNull(message = "状态不能为空") 35 @NotNull(message = "状态不能为空")
  36 + @DiffLogField(name = "状态", function = "getProductStatusName")
32 private Integer status; 37 private Integer status;
33 38
34 @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") 39 @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
35 @NotNull(message = "产品分类编号不能为空") 40 @NotNull(message = "产品分类编号不能为空")
  41 + @DiffLogField(name = "产品分类编号")
36 private Long categoryId; 42 private Long categoryId;
37 43
38 @Schema(description = "产品描述", example = "你说的对") 44 @Schema(description = "产品描述", example = "你说的对")
  45 + @DiffLogField(name = "产品描述")
39 private String description; 46 private String description;
40 47
41 @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") 48 @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926")
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.framework.operatelog.core;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
  5 +import cn.iocoder.yudao.module.crm.enums.DictTypeConstants;
  6 +import com.mzt.logapi.service.IParseFunction;
  7 +import lombok.extern.slf4j.Slf4j;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +/**
  11 + * 产品状态的 {@link IParseFunction} 实现类
  12 + *
  13 + * @author anhaohao
  14 + */
  15 +@Component
  16 +@Slf4j
  17 +public class CrmProductStatusParseFunction implements IParseFunction {
  18 +
  19 + public static final String NAME = "getProductStatusName";
  20 +
  21 + @Override
  22 + public boolean executeBefore() {
  23 + return true; // 先转换值后对比
  24 + }
  25 +
  26 + @Override
  27 + public String functionName() {
  28 + return NAME;
  29 + }
  30 +
  31 + @Override
  32 + public String apply(Object value) {
  33 + if (StrUtil.isEmptyIfStr(value)) {
  34 + return "";
  35 + }
  36 + return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_STATUS, value.toString());
  37 + }
  38 +
  39 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java 0 → 100644
  1 +package cn.iocoder.yudao.module.crm.framework.operatelog.core;
  2 +
  3 +import cn.hutool.core.util.StrUtil;
  4 +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
  5 +import cn.iocoder.yudao.module.crm.enums.DictTypeConstants;
  6 +import com.mzt.logapi.service.IParseFunction;
  7 +import lombok.extern.slf4j.Slf4j;
  8 +import org.springframework.stereotype.Component;
  9 +
  10 +/**
  11 + * 产品单位的 {@link IParseFunction} 实现类
  12 + *
  13 + * @author anhaohao
  14 + */
  15 +@Component
  16 +@Slf4j
  17 +public class CrmProductUnitParseFunction implements IParseFunction {
  18 +
  19 + public static final String NAME = "getProductUnitName";
  20 +
  21 + @Override
  22 + public boolean executeBefore() {
  23 + return true; // 先转换值后对比
  24 + }
  25 +
  26 + @Override
  27 + public String functionName() {
  28 + return NAME;
  29 + }
  30 +
  31 + @Override
  32 + public String apply(Object value) {
  33 + if (StrUtil.isEmptyIfStr(value)) {
  34 + return "";
  35 + }
  36 + return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_UNIT, value.toString());
  37 + }
  38 +
  39 +}
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java
@@ -5,15 +5,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProdu @@ -5,15 +5,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProdu
5 import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; 5 import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO;
6 import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; 6 import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO;
7 import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper; 7 import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper;
8 -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum;  
9 -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum;  
10 -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; 8 +import com.mzt.logapi.context.LogRecordContext;
11 import com.mzt.logapi.starter.annotation.LogRecord; 9 import com.mzt.logapi.starter.annotation.LogRecord;
  10 +import jakarta.annotation.Resource;
12 import org.springframework.context.annotation.Lazy; 11 import org.springframework.context.annotation.Lazy;
13 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
14 import org.springframework.validation.annotation.Validated; 13 import org.springframework.validation.annotation.Validated;
15 14
16 -import jakarta.annotation.Resource;  
17 import java.util.Collection; 15 import java.util.Collection;
18 import java.util.List; 16 import java.util.List;
19 import java.util.Objects; 17 import java.util.Objects;
@@ -40,10 +38,8 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService @@ -40,10 +38,8 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
40 private CrmProductService crmProductService; 38 private CrmProductService crmProductService;
41 39
42 @Override 40 @Override
43 - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#createReqVO.id}}", 41 + @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#productCategoryId}}",
44 success = CRM_PRODUCT_CATEGORY_CREATE_SUCCESS) 42 success = CRM_PRODUCT_CATEGORY_CREATE_SUCCESS)
45 - // TODO @hao:产品分类,应该没数据权限。可以删除下哈;  
46 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#createReqVO.id", level = CrmPermissionLevelEnum.WRITE)  
47 public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) { 43 public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) {
48 // 1.1 校验父分类存在 44 // 1.1 校验父分类存在
49 validateParentProductCategory(createReqVO.getParentId()); 45 validateParentProductCategory(createReqVO.getParentId());
@@ -53,13 +49,14 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService @@ -53,13 +49,14 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
53 // 2. 插入分类 49 // 2. 插入分类
54 CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); 50 CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class);
55 productCategoryMapper.insert(category); 51 productCategoryMapper.insert(category);
  52 + // 记录操作日志上下文
  53 + LogRecordContext.putVariable("productCategoryId", category.getId());
56 return category.getId(); 54 return category.getId();
57 } 55 }
58 56
59 @Override 57 @Override
60 @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", 58 @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}",
61 success = CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS) 59 success = CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS)
62 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE)  
63 public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) { 60 public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) {
64 // 1.1 校验存在 61 // 1.1 校验存在
65 validateProductCategoryExists(updateReqVO.getId()); 62 validateProductCategoryExists(updateReqVO.getId());
@@ -107,7 +104,6 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService @@ -107,7 +104,6 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
107 @Override 104 @Override
108 @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE, bizNo = "{{#id}}", 105 @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE, bizNo = "{{#id}}",
109 success = CRM_PRODUCT_CATEGORY_DELETE_SUCCESS) 106 success = CRM_PRODUCT_CATEGORY_DELETE_SUCCESS)
110 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER)  
111 public void deleteProductCategory(Long id) { 107 public void deleteProductCategory(Long id) {
112 // 1.1 校验存在 108 // 1.1 校验存在
113 validateProductCategoryExists(id); 109 validateProductCategoryExists(id);
@@ -124,19 +120,16 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService @@ -124,19 +120,16 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService
124 } 120 }
125 121
126 @Override 122 @Override
127 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.READ)  
128 public CrmProductCategoryDO getProductCategory(Long id) { 123 public CrmProductCategoryDO getProductCategory(Long id) {
129 return productCategoryMapper.selectById(id); 124 return productCategoryMapper.selectById(id);
130 } 125 }
131 126
132 @Override 127 @Override
133 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#listReqVO.id", level = CrmPermissionLevelEnum.READ)  
134 public List<CrmProductCategoryDO> getProductCategoryList(CrmProductCategoryListReqVO listReqVO) { 128 public List<CrmProductCategoryDO> getProductCategoryList(CrmProductCategoryListReqVO listReqVO) {
135 return productCategoryMapper.selectList(listReqVO); 129 return productCategoryMapper.selectList(listReqVO);
136 } 130 }
137 131
138 @Override 132 @Override
139 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#listReqVO.id", level = CrmPermissionLevelEnum.READ)  
140 public List<CrmProductCategoryDO> getProductCategoryList(Collection<Long> ids) { 133 public List<CrmProductCategoryDO> getProductCategoryList(Collection<Long> ids) {
141 return productCategoryMapper.selectBatchIds(ids); 134 return productCategoryMapper.selectBatchIds(ids);
142 } 135 }
yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java
@@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; @@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService;
16 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; 16 import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO;
17 import cn.iocoder.yudao.module.system.api.user.AdminUserApi; 17 import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
18 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 18 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  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;
@@ -53,9 +55,8 @@ public class CrmProductServiceImpl implements CrmProductService { @@ -53,9 +55,8 @@ public class CrmProductServiceImpl implements CrmProductService {
53 55
54 @Override 56 @Override
55 @Transactional(rollbackFor = Exception.class) 57 @Transactional(rollbackFor = Exception.class)
56 - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#createReqVO.id}}", 58 + @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#productId}}",
57 success = CRM_PRODUCT_CREATE_SUCCESS) 59 success = CRM_PRODUCT_CREATE_SUCCESS)
58 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#createReqVO.id", level = CrmPermissionLevelEnum.WRITE)  
59 public Long createProduct(CrmProductSaveReqVO createReqVO) { 60 public Long createProduct(CrmProductSaveReqVO createReqVO) {
60 // 校验产品 61 // 校验产品
61 adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); 62 adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId()));
@@ -70,6 +71,9 @@ public class CrmProductServiceImpl implements CrmProductService { @@ -70,6 +71,9 @@ public class CrmProductServiceImpl implements CrmProductService {
70 permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId()) 71 permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId())
71 .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId()) 72 .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId())
72 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); 73 .setLevel(CrmPermissionLevelEnum.OWNER.getLevel()));
  74 +
  75 + // 记录操作日志上下文
  76 + LogRecordContext.putVariable("productId", product.getId());
73 return product.getId(); 77 return product.getId();
74 } 78 }
75 79
@@ -80,20 +84,24 @@ public class CrmProductServiceImpl implements CrmProductService { @@ -80,20 +84,24 @@ public class CrmProductServiceImpl implements CrmProductService {
80 public void updateProduct(CrmProductSaveReqVO updateReqVO) { 84 public void updateProduct(CrmProductSaveReqVO updateReqVO) {
81 // 校验产品 85 // 校验产品
82 updateReqVO.setOwnerUserId(null); // 不修改负责人 86 updateReqVO.setOwnerUserId(null); // 不修改负责人
83 - validateProductExists(updateReqVO.getId()); 87 + CrmProductDO crmProductDO = validateProductExists(updateReqVO.getId());
84 validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo()); 88 validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo());
85 validateProductCategoryExists(updateReqVO.getCategoryId()); 89 validateProductCategoryExists(updateReqVO.getCategoryId());
86 90
87 // 更新产品 91 // 更新产品
88 CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class); 92 CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class);
89 productMapper.updateById(updateObj); 93 productMapper.updateById(updateObj);
  94 +
  95 + // 记录操作日志上下文
  96 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(crmProductDO,CrmProductSaveReqVO.class));
90 } 97 }
91 98
92 - private void validateProductExists(Long id) { 99 + private CrmProductDO validateProductExists(Long id) {
93 CrmProductDO product = productMapper.selectById(id); 100 CrmProductDO product = productMapper.selectById(id);
94 if (product == null) { 101 if (product == null) {
95 throw exception(PRODUCT_NOT_EXISTS); 102 throw exception(PRODUCT_NOT_EXISTS);
96 } 103 }
  104 + return product;
97 } 105 }
98 106
99 private void validateProductNoDuplicate(Long id, String no) { 107 private void validateProductNoDuplicate(Long id, String no) {
@@ -138,7 +146,6 @@ public class CrmProductServiceImpl implements CrmProductService { @@ -138,7 +146,6 @@ public class CrmProductServiceImpl implements CrmProductService {
138 } 146 }
139 147
140 @Override 148 @Override
141 - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#pageReqVO.id", level = CrmPermissionLevelEnum.READ)  
142 public PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO) { 149 public PageResult<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO) {
143 return productMapper.selectPage(pageReqVO); 150 return productMapper.selectPage(pageReqVO);
144 } 151 }