From 6891b75e27c41608c4dc70adcecf2feb9f472ff0 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sat, 13 Jan 2024 10:25:04 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=96=20CRM=EF=BC=9A=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E6=A8=A1=E5=9D=97=E7=9A=84=20review?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/product/CrmProductController.java | 3 +-- .../product/vo/product/CrmProductSaveReqVO.java | 6 ++++-- .../product/CrmProductCategoryServiceImpl.java | 3 ++- .../service/product/CrmProductServiceImpl.java | 15 ++++++++------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java index a21728b12..3bf16cf1e 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/CrmProductController.java @@ -136,8 +136,7 @@ public class CrmProductController { public CommonResult> getProductOperateLog(@RequestParam("bizId") Long bizId) { OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO(); reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 - reqVO.setBizType(CRM_PRODUCT_TYPE); - reqVO.setBizId(bizId); + reqVO.setBizType(CRM_PRODUCT_TYPE).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/product/vo/product/CrmProductSaveReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java index 74fa70d4d..01b2ae443 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/product/CrmProductSaveReqVO.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; +import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductStatusParseFunction; +import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmProductUnitParseFunction; import com.mzt.logapi.starter.annotation.DiffLogField; import io.swagger.v3.oas.annotations.media.Schema; import jakarta.validation.constraints.NotNull; @@ -23,7 +25,7 @@ public class CrmProductSaveReqVO { private String no; @Schema(description = "单位", example = "2") - @DiffLogField(name = "单位", function = "getProductUnitName") + @DiffLogField(name = "单位", function = CrmProductUnitParseFunction.NAME) private Integer unit; @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") @@ -33,7 +35,7 @@ public class CrmProductSaveReqVO { @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") @NotNull(message = "状态不能为空") - @DiffLogField(name = "状态", function = "getProductStatusName") + @DiffLogField(name = "状态", function = CrmProductStatusParseFunction.NAME) private Integer status; @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java index 25d564c16..6399039ba 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductCategoryServiceImpl.java @@ -49,7 +49,8 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService // 2. 插入分类 CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); productCategoryMapper.insert(category); - // 记录操作日志上下文 + + // 3. 记录操作日志上下文 LogRecordContext.putVariable("productCategoryId", category.getId()); return category.getId(); } diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java index 06722ba02..edf518b05 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/service/product/CrmProductServiceImpl.java @@ -58,21 +58,21 @@ public class CrmProductServiceImpl implements CrmProductService { @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#productId}}", success = CRM_PRODUCT_CREATE_SUCCESS) public Long createProduct(CrmProductSaveReqVO createReqVO) { - // 校验产品 + // 1. 校验产品 adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); validateProductNoDuplicate(null, createReqVO.getNo()); validateProductCategoryExists(createReqVO.getCategoryId()); - // 插入产品 + // 2. 插入产品 CrmProductDO product = BeanUtils.toBean(createReqVO, CrmProductDO.class); productMapper.insert(product); - // 插入数据权限 + // 3. 插入数据权限 permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId()) .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId()) .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); - // 记录操作日志上下文 + // 4. 记录操作日志上下文 LogRecordContext.putVariable("productId", product.getId()); return product.getId(); } @@ -82,17 +82,17 @@ public class CrmProductServiceImpl implements CrmProductService { success = CRM_PRODUCT_UPDATE_SUCCESS) @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) public void updateProduct(CrmProductSaveReqVO updateReqVO) { - // 校验产品 + // 1. 校验产品 updateReqVO.setOwnerUserId(null); // 不修改负责人 CrmProductDO crmProductDO = validateProductExists(updateReqVO.getId()); validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo()); validateProductCategoryExists(updateReqVO.getCategoryId()); - // 更新产品 + // 2. 更新产品 CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class); productMapper.updateById(updateObj); - // 记录操作日志上下文 + // 3. 记录操作日志上下文 LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(crmProductDO,CrmProductSaveReqVO.class)); } @@ -145,6 +145,7 @@ public class CrmProductServiceImpl implements CrmProductService { return productMapper.selectBatchIds(ids); } + // TODO @anhaohao:可以接入数据权限,参考 CrmCustomerService 的 getCustomerPage @Override public PageResult getProductPage(CrmProductPageReqVO pageReqVO) { return productMapper.selectPage(pageReqVO);