mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
📖 CRM:产品模块的 review
This commit is contained in:
parent
19c0227cef
commit
6891b75e27
@ -136,8 +136,7 @@ public class CrmProductController {
|
||||
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);
|
||||
reqVO.setBizType(CRM_PRODUCT_TYPE).setBizId(bizId);
|
||||
return success(operateLogApi.getOperateLogPage(BeanUtils.toBean(reqVO, OperateLogV2PageReqDTO.class)));
|
||||
}
|
||||
|
||||
|
@ -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")
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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<CrmProductDO> getProductPage(CrmProductPageReqVO pageReqVO) {
|
||||
return productMapper.selectPage(pageReqVO);
|
||||
|
Loading…
Reference in New Issue
Block a user