Commit 008f88d1856b5ba9215688c2808e818c19898cf3
1 parent
803816b1
新增:CRM 产品,新增获得产品操作日志
Showing
1 changed file
with
24 additions
and
6 deletions
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; | @@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; | 7 | import cn.iocoder.yudao.framework.common.util.collection.SetUtils; |
| 8 | +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||
| 8 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | 9 | import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; |
| 9 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | 10 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 10 | import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; | 11 | 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; | @@ -15,18 +16,21 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductCategoryDO; | ||
| 15 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; | 16 | import cn.iocoder.yudao.module.crm.dal.dataobject.product.CrmProductDO; |
| 16 | import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; | 17 | import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; |
| 17 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; | 18 | import cn.iocoder.yudao.module.crm.service.product.CrmProductService; |
| 19 | +import cn.iocoder.yudao.module.system.api.logger.OperateLogApi; | ||
| 20 | +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2PageReqDTO; | ||
| 21 | +import cn.iocoder.yudao.module.system.api.logger.dto.OperateLogV2RespDTO; | ||
| 18 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | 22 | import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 19 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | 23 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 20 | import io.swagger.v3.oas.annotations.Operation; | 24 | import io.swagger.v3.oas.annotations.Operation; |
| 21 | import io.swagger.v3.oas.annotations.Parameter; | 25 | import io.swagger.v3.oas.annotations.Parameter; |
| 22 | import io.swagger.v3.oas.annotations.tags.Tag; | 26 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 27 | +import jakarta.annotation.Resource; | ||
| 28 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 29 | +import jakarta.validation.Valid; | ||
| 23 | import org.springframework.security.access.prepost.PreAuthorize; | 30 | import org.springframework.security.access.prepost.PreAuthorize; |
| 24 | import org.springframework.validation.annotation.Validated; | 31 | import org.springframework.validation.annotation.Validated; |
| 25 | import org.springframework.web.bind.annotation.*; | 32 | import org.springframework.web.bind.annotation.*; |
| 26 | 33 | ||
| 27 | -import jakarta.annotation.Resource; | ||
| 28 | -import jakarta.servlet.http.HttpServletResponse; | ||
| 29 | -import jakarta.validation.Valid; | ||
| 30 | import java.io.IOException; | 34 | import java.io.IOException; |
| 31 | import java.util.Collections; | 35 | import java.util.Collections; |
| 32 | import java.util.List; | 36 | import java.util.List; |
| @@ -34,9 +38,11 @@ import java.util.Map; | @@ -34,9 +38,11 @@ import java.util.Map; | ||
| 34 | import java.util.stream.Stream; | 38 | import java.util.stream.Stream; |
| 35 | 39 | ||
| 36 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 40 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 41 | +import static cn.iocoder.yudao.framework.common.pojo.PageParam.PAGE_SIZE_NONE; | ||
| 37 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 42 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 38 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; | 43 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; |
| 39 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | 44 | import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; |
| 45 | +import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_PRODUCT_TYPE; | ||
| 40 | 46 | ||
| 41 | @Tag(name = "管理后台 - CRM 产品") | 47 | @Tag(name = "管理后台 - CRM 产品") |
| 42 | @RestController | 48 | @RestController |
| @@ -48,7 +54,8 @@ public class CrmProductController { | @@ -48,7 +54,8 @@ public class CrmProductController { | ||
| 48 | private CrmProductService productService; | 54 | private CrmProductService productService; |
| 49 | @Resource | 55 | @Resource |
| 50 | private CrmProductCategoryService productCategoryService; | 56 | private CrmProductCategoryService productCategoryService; |
| 51 | - | 57 | + @Resource |
| 58 | + private OperateLogApi operateLogApi; | ||
| 52 | @Resource | 59 | @Resource |
| 53 | private AdminUserApi adminUserApi; | 60 | private AdminUserApi adminUserApi; |
| 54 | 61 | ||
| @@ -86,7 +93,7 @@ public class CrmProductController { | @@ -86,7 +93,7 @@ public class CrmProductController { | ||
| 86 | return success(null); | 93 | return success(null); |
| 87 | } | 94 | } |
| 88 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | 95 | Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( |
| 89 | - SetUtils.asSet( Long.valueOf(product.getCreator()), product.getOwnerUserId())); | 96 | + SetUtils.asSet(Long.valueOf(product.getCreator()), product.getOwnerUserId())); |
| 90 | CrmProductCategoryDO category = productCategoryService.getProductCategory(product.getCategoryId()); | 97 | CrmProductCategoryDO category = productCategoryService.getProductCategory(product.getCategoryId()); |
| 91 | return success(CrmProductConvert.INSTANCE.convert(product, userMap, category)); | 98 | return success(CrmProductConvert.INSTANCE.convert(product, userMap, category)); |
| 92 | } | 99 | } |
| @@ -104,7 +111,7 @@ public class CrmProductController { | @@ -104,7 +111,7 @@ public class CrmProductController { | ||
| 104 | @PreAuthorize("@ss.hasPermission('crm:product:export')") | 111 | @PreAuthorize("@ss.hasPermission('crm:product:export')") |
| 105 | @OperateLog(type = EXPORT) | 112 | @OperateLog(type = EXPORT) |
| 106 | public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, | 113 | public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, |
| 107 | - HttpServletResponse response) throws IOException { | 114 | + HttpServletResponse response) throws IOException { |
| 108 | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | 115 | exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); |
| 109 | List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList(); | 116 | List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList(); |
| 110 | // 导出 Excel | 117 | // 导出 Excel |
| @@ -123,4 +130,15 @@ public class CrmProductController { | @@ -123,4 +130,15 @@ public class CrmProductController { | ||
| 123 | return CrmProductConvert.INSTANCE.convertList(list, userMap, productCategoryList); | 130 | return CrmProductConvert.INSTANCE.convertList(list, userMap, productCategoryList); |
| 124 | } | 131 | } |
| 125 | 132 | ||
| 133 | + @GetMapping("/operate-log-page") | ||
| 134 | + @Operation(summary = "获得产品操作日志") | ||
| 135 | + @PreAuthorize("@ss.hasPermission('crm:product:query')") | ||
| 136 | + public CommonResult<PageResult<OperateLogV2RespDTO>> getProductOperateLog(@RequestParam("bizId") Long bizId) { | ||
| 137 | + OperateLogV2PageReqDTO reqVO = new OperateLogV2PageReqDTO(); | ||
| 138 | + reqVO.setPageSize(PAGE_SIZE_NONE); // 不分页 | ||
| 139 | + reqVO.setBizType(CRM_PRODUCT_TYPE); | ||
| 140 | + reqVO.setBizId(bizId); | ||
| 141 | + return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class))); | ||
| 142 | + } | ||
| 143 | + | ||
| 126 | } | 144 | } |