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

This commit is contained in:
anhaohao 2024-01-11 17:45:09 +08:00
parent 803816b162
commit 008f88d185

View File

@ -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.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.SetUtils; 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.excel.core.util.ExcelUtils;
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
import cn.iocoder.yudao.module.crm.controller.admin.product.vo.product.CrmProductPageReqVO; 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.dal.dataobject.product.CrmProductDO;
import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService; import cn.iocoder.yudao.module.crm.service.product.CrmProductCategoryService;
import cn.iocoder.yudao.module.crm.service.product.CrmProductService; 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.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; 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.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; 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.io.IOException;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -34,9 +38,11 @@ import java.util.Map;
import java.util.stream.Stream; import java.util.stream.Stream;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; 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.convertSet;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; 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.framework.operatelog.core.enums.OperateTypeEnum.EXPORT;
import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.CRM_PRODUCT_TYPE;
@Tag(name = "管理后台 - CRM 产品") @Tag(name = "管理后台 - CRM 产品")
@RestController @RestController
@ -48,7 +54,8 @@ public class CrmProductController {
private CrmProductService productService; private CrmProductService productService;
@Resource @Resource
private CrmProductCategoryService productCategoryService; private CrmProductCategoryService productCategoryService;
@Resource
private OperateLogApi operateLogApi;
@Resource @Resource
private AdminUserApi adminUserApi; private AdminUserApi adminUserApi;
@ -86,7 +93,7 @@ public class CrmProductController {
return success(null); return success(null);
} }
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( 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()); CrmProductCategoryDO category = productCategoryService.getProductCategory(product.getCategoryId());
return success(CrmProductConvert.INSTANCE.convert(product, userMap, category)); return success(CrmProductConvert.INSTANCE.convert(product, userMap, category));
} }
@ -104,7 +111,7 @@ public class CrmProductController {
@PreAuthorize("@ss.hasPermission('crm:product:export')") @PreAuthorize("@ss.hasPermission('crm:product:export')")
@OperateLog(type = EXPORT) @OperateLog(type = EXPORT)
public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO, public void exportProductExcel(@Valid CrmProductPageReqVO exportReqVO,
HttpServletResponse response) throws IOException { HttpServletResponse response) throws IOException {
exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); exportReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList(); List<CrmProductDO> list = productService.getProductPage(exportReqVO).getList();
// 导出 Excel // 导出 Excel
@ -123,4 +130,15 @@ public class CrmProductController {
return CrmProductConvert.INSTANCE.convertList(list, userMap, productCategoryList); 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)));
}
} }