From 803816b162b202e0c2200a00b0549f11f59ae75b Mon Sep 17 00:00:00 2001 From: anhaohao <1036606149@qq.com> Date: Thu, 11 Jan 2024 16:02:05 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9ACRM=20=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=E5=92=8C=E4=BA=A7=E5=93=81=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BA=86=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/crm/enums/LogRecordConstants.java | 4 +- .../CrmProductCategoryCreateReqVO.java | 2 + .../vo/product/CrmProductSaveReqVO.java | 11 +++++- .../core/CrmProductStatusParseFunction.java | 39 +++++++++++++++++++ .../core/CrmProductUnitParseFunction.java | 39 +++++++++++++++++++ .../CrmProductCategoryServiceImpl.java | 17 +++----- .../product/CrmProductServiceImpl.java | 17 +++++--- 7 files changed, 109 insertions(+), 20 deletions(-) create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java create mode 100644 yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java diff --git a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java b/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java index 057932ad8..604734046 100644 --- a/yudao-module-crm/yudao-module-crm-api/src/main/java/cn/iocoder/yudao/module/crm/enums/LogRecordConstants.java +++ b/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 { // ======================= CRM_PRODUCT 产品 ======================= - // TODO @hao:可以把 CRM 产品、和 CRM 产品分类分开哈,量程两个 type; String CRM_PRODUCT_TYPE = "CRM 产品"; String CRM_PRODUCT_CREATE_SUB_TYPE = "创建产品"; String CRM_PRODUCT_CREATE_SUCCESS = "创建了产品【{{#createReqVO.name}}】"; @@ -68,6 +67,9 @@ public interface LogRecordConstants { String CRM_PRODUCT_UPDATE_SUCCESS = "更新了产品【{{#updateReqVO.name}}】: {_DIFF{#updateReqVO}}"; String CRM_PRODUCT_DELETE_SUB_TYPE = "删除产品"; String CRM_PRODUCT_DELETE_SUCCESS = "删除了产品【{{#product.name}}】"; + + // ======================= CRM_PRODUCT_CATEGORY 产品分类 ======================= + String CRM_PRODUCT_CATEGORY_TYPE = "CRM 产品分类"; String CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE = "创建产品分类"; String CRM_PRODUCT_CATEGORY_CREATE_SUCCESS = "创建了产品分类【{{#createReqVO.name}}】"; diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java index 6772612f4..bb17806a8 100644 --- a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/controller/admin/product/vo/category/CrmProductCategoryCreateReqVO.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.crm.controller.admin.product.vo.category; +import com.mzt.logapi.starter.annotation.DiffLogField; import lombok.*; import io.swagger.v3.oas.annotations.media.Schema; @@ -14,6 +15,7 @@ public class CrmProductCategoryCreateReqVO{ @Schema(description = "分类名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六") @NotNull(message = "分类名称不能为空") + @DiffLogField(name = "分类名称") private String name; @Schema(description = "父级编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "4680") 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 c6c3919e9..74fa70d4d 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,9 +1,9 @@ package cn.iocoder.yudao.module.crm.controller.admin.product.vo.product; -import lombok.*; +import com.mzt.logapi.starter.annotation.DiffLogField; import io.swagger.v3.oas.annotations.media.Schema; - import jakarta.validation.constraints.NotNull; +import lombok.Data; @Schema(description = "管理后台 - CRM 产品创建/修改 Request VO") @Data @@ -14,28 +14,35 @@ public class CrmProductSaveReqVO { @Schema(description = "产品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "好产品") @NotNull(message = "产品名称不能为空") + @DiffLogField(name = "产品名称") private String name; @Schema(description = "产品编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "12306") @NotNull(message = "产品编码不能为空") + @DiffLogField(name = "产品编码") private String no; @Schema(description = "单位", example = "2") + @DiffLogField(name = "单位", function = "getProductUnitName") private Integer unit; @Schema(description = "价格, 单位:分", requiredMode = Schema.RequiredMode.REQUIRED, example = "8911") @NotNull(message = "价格不能为空") + @DiffLogField(name = "价格") private Long price; @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "上架") @NotNull(message = "状态不能为空") + @DiffLogField(name = "状态", function = "getProductStatusName") private Integer status; @Schema(description = "产品分类编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "2") @NotNull(message = "产品分类编号不能为空") + @DiffLogField(name = "产品分类编号") private Long categoryId; @Schema(description = "产品描述", example = "你说的对") + @DiffLogField(name = "产品描述") private String description; @Schema(description = "负责人的用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "31926") diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java new file mode 100644 index 000000000..cf81f5e31 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductStatusParseFunction.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.crm.framework.operatelog.core; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; +import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; +import com.mzt.logapi.service.IParseFunction; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 产品状态的 {@link IParseFunction} 实现类 + * + * @author anhaohao + */ +@Component +@Slf4j +public class CrmProductStatusParseFunction implements IParseFunction { + + public static final String NAME = "getProductStatusName"; + + @Override + public boolean executeBefore() { + return true; // 先转换值后对比 + } + + @Override + public String functionName() { + return NAME; + } + + @Override + public String apply(Object value) { + if (StrUtil.isEmptyIfStr(value)) { + return ""; + } + return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_STATUS, value.toString()); + } + +} diff --git a/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java new file mode 100644 index 000000000..898bedd07 --- /dev/null +++ b/yudao-module-crm/yudao-module-crm-biz/src/main/java/cn/iocoder/yudao/module/crm/framework/operatelog/core/CrmProductUnitParseFunction.java @@ -0,0 +1,39 @@ +package cn.iocoder.yudao.module.crm.framework.operatelog.core; + +import cn.hutool.core.util.StrUtil; +import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils; +import cn.iocoder.yudao.module.crm.enums.DictTypeConstants; +import com.mzt.logapi.service.IParseFunction; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +/** + * 产品单位的 {@link IParseFunction} 实现类 + * + * @author anhaohao + */ +@Component +@Slf4j +public class CrmProductUnitParseFunction implements IParseFunction { + + public static final String NAME = "getProductUnitName"; + + @Override + public boolean executeBefore() { + return true; // 先转换值后对比 + } + + @Override + public String functionName() { + return NAME; + } + + @Override + public String apply(Object value) { + if (StrUtil.isEmptyIfStr(value)) { + return ""; + } + return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.CRM_PRODUCT_UNIT, value.toString()); + } + +} 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 7996efca9..25d564c16 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 @@ -5,15 +5,13 @@ import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProdu import cn.iocoder.yudao.module.crm.controller.admin.product.vo.category.CrmProductCategoryListReqVO; import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; import cn.iocoder.yudao.module.crm.dal.mysql.product.CrmProductCategoryMapper; -import cn.iocoder.yudao.module.crm.enums.common.CrmBizTypeEnum; -import cn.iocoder.yudao.module.crm.enums.permission.CrmPermissionLevelEnum; -import cn.iocoder.yudao.module.crm.framework.permission.core.annotations.CrmPermission; +import com.mzt.logapi.context.LogRecordContext; import com.mzt.logapi.starter.annotation.LogRecord; +import jakarta.annotation.Resource; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; -import jakarta.annotation.Resource; import java.util.Collection; import java.util.List; import java.util.Objects; @@ -40,10 +38,8 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService private CrmProductService crmProductService; @Override - @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#createReqVO.id}}", + @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_CREATE_SUB_TYPE, bizNo = "{{#productCategoryId}}", success = CRM_PRODUCT_CATEGORY_CREATE_SUCCESS) - // TODO @hao:产品分类,应该没数据权限。可以删除下哈; - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#createReqVO.id", level = CrmPermissionLevelEnum.WRITE) public Long createProductCategory(CrmProductCategoryCreateReqVO createReqVO) { // 1.1 校验父分类存在 validateParentProductCategory(createReqVO.getParentId()); @@ -53,13 +49,14 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService // 2. 插入分类 CrmProductCategoryDO category = BeanUtils.toBean(createReqVO, CrmProductCategoryDO.class); productCategoryMapper.insert(category); + // 记录操作日志上下文 + LogRecordContext.putVariable("productCategoryId", category.getId()); return category.getId(); } @Override @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_PRODUCT_CATEGORY_UPDATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#updateReqVO.id", level = CrmPermissionLevelEnum.WRITE) public void updateProductCategory(CrmProductCategoryCreateReqVO updateReqVO) { // 1.1 校验存在 validateProductCategoryExists(updateReqVO.getId()); @@ -107,7 +104,6 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService @Override @LogRecord(type = CRM_PRODUCT_CATEGORY_TYPE, subType = CRM_PRODUCT_CATEGORY_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_PRODUCT_CATEGORY_DELETE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.OWNER) public void deleteProductCategory(Long id) { // 1.1 校验存在 validateProductCategoryExists(id); @@ -124,19 +120,16 @@ public class CrmProductCategoryServiceImpl implements CrmProductCategoryService } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#id", level = CrmPermissionLevelEnum.READ) public CrmProductCategoryDO getProductCategory(Long id) { return productCategoryMapper.selectById(id); } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#listReqVO.id", level = CrmPermissionLevelEnum.READ) public List getProductCategoryList(CrmProductCategoryListReqVO listReqVO) { return productCategoryMapper.selectList(listReqVO); } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#listReqVO.id", level = CrmPermissionLevelEnum.READ) public List getProductCategoryList(Collection ids) { return productCategoryMapper.selectBatchIds(ids); } 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 cec0bc6c9..06722ba02 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 @@ -16,6 +16,8 @@ import cn.iocoder.yudao.module.crm.service.permission.CrmPermissionService; import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionCreateReqBO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.mzt.logapi.context.LogRecordContext; +import com.mzt.logapi.service.impl.DiffParseFunction; import com.mzt.logapi.starter.annotation.LogRecord; import jakarta.annotation.Resource; import org.springframework.stereotype.Service; @@ -53,9 +55,8 @@ public class CrmProductServiceImpl implements CrmProductService { @Override @Transactional(rollbackFor = Exception.class) - @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#createReqVO.id}}", + @LogRecord(type = CRM_PRODUCT_TYPE, subType = CRM_PRODUCT_CREATE_SUB_TYPE, bizNo = "{{#productId}}", success = CRM_PRODUCT_CREATE_SUCCESS) - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#createReqVO.id", level = CrmPermissionLevelEnum.WRITE) public Long createProduct(CrmProductSaveReqVO createReqVO) { // 校验产品 adminUserApi.validateUserList(Collections.singleton(createReqVO.getOwnerUserId())); @@ -70,6 +71,9 @@ public class CrmProductServiceImpl implements CrmProductService { permissionService.createPermission(new CrmPermissionCreateReqBO().setUserId(product.getOwnerUserId()) .setBizType(CrmBizTypeEnum.CRM_PRODUCT.getType()).setBizId(product.getId()) .setLevel(CrmPermissionLevelEnum.OWNER.getLevel())); + + // 记录操作日志上下文 + LogRecordContext.putVariable("productId", product.getId()); return product.getId(); } @@ -80,20 +84,24 @@ public class CrmProductServiceImpl implements CrmProductService { public void updateProduct(CrmProductSaveReqVO updateReqVO) { // 校验产品 updateReqVO.setOwnerUserId(null); // 不修改负责人 - validateProductExists(updateReqVO.getId()); + CrmProductDO crmProductDO = validateProductExists(updateReqVO.getId()); validateProductNoDuplicate(updateReqVO.getId(), updateReqVO.getNo()); validateProductCategoryExists(updateReqVO.getCategoryId()); // 更新产品 CrmProductDO updateObj = BeanUtils.toBean(updateReqVO, CrmProductDO.class); productMapper.updateById(updateObj); + + // 记录操作日志上下文 + LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(crmProductDO,CrmProductSaveReqVO.class)); } - private void validateProductExists(Long id) { + private CrmProductDO validateProductExists(Long id) { CrmProductDO product = productMapper.selectById(id); if (product == null) { throw exception(PRODUCT_NOT_EXISTS); } + return product; } private void validateProductNoDuplicate(Long id, String no) { @@ -138,7 +146,6 @@ public class CrmProductServiceImpl implements CrmProductService { } @Override - @CrmPermission(bizType = CrmBizTypeEnum.CRM_PRODUCT, bizId = "#pageReqVO.id", level = CrmPermissionLevelEnum.READ) public PageResult getProductPage(CrmProductPageReqVO pageReqVO) { return productMapper.selectPage(pageReqVO); } From 008f88d1856b5ba9215688c2808e818c19898cf3 Mon Sep 17 00:00:00 2001 From: anhaohao <1036606149@qq.com> Date: Thu, 11 Jan 2024 17:45:09 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=EF=BC=9ACRM=20=E4=BA=A7?= =?UTF-8?q?=E5=93=81=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=BE=97=E4=BA=A7?= =?UTF-8?q?=E5=93=81=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/product/CrmProductController.java | 30 +++++++++++++++---- 1 file changed, 24 insertions(+), 6 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 2ce156ebd..a21728b12 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 @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.util.collection.SetUtils; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; @@ -15,18 +16,21 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; import cn.iocoder.yudao.module.crm.service.product.CrmProductService; +import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO; +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import jakarta.annotation.Resource; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; import java.io.IOException; import java.util.Collections; import java.util.List; @@ -34,9 +38,11 @@ import java.util.Map; import java.util.stream.Stream; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_PRODUCT_TYPE; @Tag(name = "管理后台 - CRM 产品") @RestController @@ -48,7 +54,8 @@ public class CrmProductController { private CrmProductService productService; @Resource private CrmProductCategoryService productCategoryService; - + @Resource + private OperateLogApi operateLogApi; @Resource private AdminUserApi adminUserApi; @@ -86,7 +93,7 @@ public class CrmProductController { return success(null); } Map userMap = adminUserApi.getUserMap( - SetUtils.asSet( Long.valueOf(product.getCreator()), product.getOwnerUserId())); + SetUtils.asSet(Long.valueOf(product.getCreator()), product.getOwnerUserId())); CrmProductCategoryDO category = productCategoryService.getProductCategory(product.getCategoryId()); return success(CrmProductConvert.INSTANCE.convert(product, userMap, category)); } @@ -104,7 +111,7 @@ public class CrmProductController { @PreAuthorize("@ss.hasPermission('crm:product:export')") @OperateLog(type = EXPORT) public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, - HttpServletResponse response) throws IOException { + HttpServletResponse response) throws IOException { exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); List list = productService.getProductPage(exportReqVO).getList(); // 导出 Excel @@ -123,4 +130,15 @@ public class CrmProductController { return CrmProductConvert.INSTANCE.convertList(list, userMap, productCategoryList); } + @GetMapping("/operate-log-page") + @Operation(summary = "获得产品操作日志") + @PreAuthorize("@ss.hasPermission('crm:product:query')") + public CommonResult> getProductOperateLog(@RequestParam("bizId") Long bizId) { + OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO(); + reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 + reqVO.setBizType(CRM_PRODUCT_TYPE); + reqVO.setBizId(bizId); + return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class))); + } + }