Browse Source

新增:CRM 产品,新增获得产品操作日志

anhaohao 1 year ago
parent
commit
008f88d185

+ 24 - 6
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<Long, AdminUserRespDTO> 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<CrmProductDO> 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<PageResult<OperateLogV2RespDTO>> 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)));
+    }
+
 }