mirror of
				https://github.com/YunaiV/ruoyi-vue-pro.git
				synced 2025-10-31 18:49:06 +08:00 
			
		
		
		
	CRM-客户: 简化客户公海配置 VO,完善相关操作日志
This commit is contained in:
		| @ -30,6 +30,22 @@ public interface LogRecordConstants { | |||||||
|     String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; |     String CRM_CUSTOMER_RECEIVE_SUB_TYPE = "{{#ownerUserName != null ? '分配客户' : '领取客户'}}"; | ||||||
|     String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}"; |     String CRM_CUSTOMER_RECEIVE_SUCCESS = "{{#ownerUserName != null ? '将客户【' + #customer.name + '】分配给【' + #ownerUserName + '】' : '领取客户【' + #customer.name + '】'}}"; | ||||||
|  |  | ||||||
|  |     // ======================= CRM_CUSTOMER_LIMIT_CONFIG 客户限制配置 ======================= | ||||||
|  |  | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_TYPE = "CRM 客户限制配置"; | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE = "创建客户限制配置"; | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS = "创建了【{{#limitType}}】类型的客户限制配置"; | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE = "更新客户限制配置"; | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS = "更新了客户限制配置: {_DIFF{#updateReqVO}}"; | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE = "删除客户限制配置"; | ||||||
|  |     String CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS = "删除了【{{#limitType}}】类型的客户限制配置"; | ||||||
|  |  | ||||||
|  |     // ======================= CRM_CUSTOMER_POOL_CONFIG 客户公海规则 ======================= | ||||||
|  |  | ||||||
|  |     String CRM_CUSTOMER_POOL_CONFIG_TYPE = "CRM 客户公海规则"; | ||||||
|  |     String CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE = "{{#isPoolConfigUpdate ? '更新客户公海规则' : '创建客户公海规则'}}"; | ||||||
|  |     String CRM_CUSTOMER_POOL_CONFIG_SUCCESS = "{{#isPoolConfigUpdate ? '更新了客户公海规则' : '创建了客户公海规则'}}"; | ||||||
|  |  | ||||||
|     // ======================= CRM_CONTACT 联系人 ======================= |     // ======================= CRM_CONTACT 联系人 ======================= | ||||||
|  |  | ||||||
|     String CRM_CONTACT_TYPE = "CRM 联系人"; |     String CRM_CONTACT_TYPE = "CRM 联系人"; | ||||||
|  | |||||||
| @ -1,5 +1,7 @@ | |||||||
| package cn.iocoder.yudao.module.crm.enums.customer; | package cn.iocoder.yudao.module.crm.enums.customer; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.collection.CollUtil; | ||||||
|  | import cn.hutool.core.util.ObjUtil; | ||||||
| import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | ||||||
| import lombok.AllArgsConstructor; | import lombok.AllArgsConstructor; | ||||||
| import lombok.Getter; | import lombok.Getter; | ||||||
| @ -36,6 +38,12 @@ public enum CrmCustomerLimitConfigTypeEnum implements IntArrayValuable { | |||||||
|      */ |      */ | ||||||
|     private final String name; |     private final String name; | ||||||
|  |  | ||||||
|  |     public static String getNameByType(Integer type) { | ||||||
|  |         CrmCustomerLimitConfigTypeEnum typeEnum = CollUtil.findOne(CollUtil.newArrayList(CrmCustomerLimitConfigTypeEnum.values()), | ||||||
|  |                 item -> ObjUtil.equal(item.type, type)); | ||||||
|  |         return typeEnum == null ? null : typeEnum.getName(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public int[] array() { |     public int[] array() { | ||||||
|         return ARRAYS; |         return ARRAYS; | ||||||
|  | |||||||
| @ -8,13 +8,12 @@ import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfig | |||||||
| import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; | import cn.iocoder.yudao.module.crm.service.customer.CrmCustomerPoolConfigService; | ||||||
| import io.swagger.v3.oas.annotations.Operation; | import io.swagger.v3.oas.annotations.Operation; | ||||||
| import io.swagger.v3.oas.annotations.tags.Tag; | import io.swagger.v3.oas.annotations.tags.Tag; | ||||||
|  | import jakarta.annotation.Resource; | ||||||
|  | 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.validation.Valid; |  | ||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||||
|  |  | ||||||
| @Tag(name = "管理后台 - CRM 客户公海配置") | @Tag(name = "管理后台 - CRM 客户公海配置") | ||||||
| @ -26,7 +25,6 @@ public class CrmCustomerPoolConfigController { | |||||||
|     @Resource |     @Resource | ||||||
|     private CrmCustomerPoolConfigService customerPoolConfigService; |     private CrmCustomerPoolConfigService customerPoolConfigService; | ||||||
|  |  | ||||||
|     // TODO @puhui999:可以把 vo 改下哈 |  | ||||||
|     @GetMapping("/get") |     @GetMapping("/get") | ||||||
|     @Operation(summary = "获取客户公海规则设置") |     @Operation(summary = "获取客户公海规则设置") | ||||||
|     @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") |     @PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')") | ||||||
|  | |||||||
| @ -1,31 +0,0 @@ | |||||||
| package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; |  | ||||||
|  |  | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; |  | ||||||
| import lombok.Data; |  | ||||||
|  |  | ||||||
| import jakarta.validation.constraints.NotNull; |  | ||||||
|  |  | ||||||
| /** |  | ||||||
|  * 客户公海配置 Base VO,提供给添加、修改、详细的子 VO 使用 |  | ||||||
|  * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 |  | ||||||
|  */ |  | ||||||
| @Data |  | ||||||
| public class CrmCustomerPoolConfigBaseVO { |  | ||||||
|  |  | ||||||
|     @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") |  | ||||||
|     @NotNull(message = "是否启用客户公海不能为空") |  | ||||||
|     private Boolean enabled; |  | ||||||
|  |  | ||||||
|     @Schema(description = "未跟进放入公海天数", example = "2") |  | ||||||
|     private Integer contactExpireDays; |  | ||||||
|  |  | ||||||
|     @Schema(description = "未成交放入公海天数", example = "2") |  | ||||||
|     private Integer dealExpireDays; |  | ||||||
|  |  | ||||||
|     @Schema(description = "是否开启提前提醒", example = "true") |  | ||||||
|     private Boolean notifyEnabled; |  | ||||||
|  |  | ||||||
|     @Schema(description = "提前提醒天数", example = "2") |  | ||||||
|     private Integer notifyDays; |  | ||||||
|  |  | ||||||
| } |  | ||||||
| @ -1,14 +1,27 @@ | |||||||
| package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | ||||||
|  |  | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
|  | import jakarta.validation.constraints.NotNull; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
| import lombok.EqualsAndHashCode; |  | ||||||
| import lombok.ToString; |  | ||||||
|  |  | ||||||
| @Schema(description = "管理后台 - CRM 客户公海规则 Response VO") | @Schema(description = "管理后台 - CRM 客户公海规则 Response VO") | ||||||
| @Data | @Data | ||||||
| @EqualsAndHashCode(callSuper = true) | public class CrmCustomerPoolConfigRespVO { | ||||||
| @ToString(callSuper = true) |  | ||||||
| public class CrmCustomerPoolConfigRespVO extends CrmCustomerPoolConfigBaseVO { |     @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||||||
|  |     @NotNull(message = "是否启用客户公海不能为空") | ||||||
|  |     private Boolean enabled; | ||||||
|  |  | ||||||
|  |     @Schema(description = "未跟进放入公海天数", example = "2") | ||||||
|  |     private Integer contactExpireDays; | ||||||
|  |  | ||||||
|  |     @Schema(description = "未成交放入公海天数", example = "2") | ||||||
|  |     private Integer dealExpireDays; | ||||||
|  |  | ||||||
|  |     @Schema(description = "是否开启提前提醒", example = "true") | ||||||
|  |     private Boolean notifyEnabled; | ||||||
|  |  | ||||||
|  |     @Schema(description = "提前提醒天数", example = "2") | ||||||
|  |     private Integer notifyDays; | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
| @ -2,19 +2,38 @@ package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig; | |||||||
|  |  | ||||||
| import cn.hutool.core.util.BooleanUtil; | import cn.hutool.core.util.BooleanUtil; | ||||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | import com.fasterxml.jackson.annotation.JsonIgnore; | ||||||
|  | import com.mzt.logapi.starter.annotation.DiffLogField; | ||||||
| import io.swagger.v3.oas.annotations.media.Schema; | import io.swagger.v3.oas.annotations.media.Schema; | ||||||
| import jakarta.validation.constraints.AssertTrue; | import jakarta.validation.constraints.AssertTrue; | ||||||
|  | import jakarta.validation.constraints.NotNull; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
| import lombok.EqualsAndHashCode; |  | ||||||
| import lombok.ToString; |  | ||||||
|  |  | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
| @Schema(description = "管理后台 - CRM 客户公海配置的保存 Request VO") | @Schema(description = "管理后台 - CRM 客户公海配置的创建/更新 Request VO") | ||||||
| @Data | @Data | ||||||
| @EqualsAndHashCode(callSuper = true) | public class CrmCustomerPoolConfigSaveReqVO { | ||||||
| @ToString(callSuper = true) |  | ||||||
| public class CrmCustomerPoolConfigSaveReqVO extends CrmCustomerPoolConfigBaseVO { |     @Schema(description = "是否启用客户公海", requiredMode = Schema.RequiredMode.REQUIRED, example = "true") | ||||||
|  |     @DiffLogField(name = "是否启用客户公海") | ||||||
|  |     @NotNull(message = "是否启用客户公海不能为空") | ||||||
|  |     private Boolean enabled; | ||||||
|  |  | ||||||
|  |     @Schema(description = "未跟进放入公海天数", example = "2") | ||||||
|  |     @DiffLogField(name = "未跟进放入公海天数") | ||||||
|  |     private Integer contactExpireDays; | ||||||
|  |  | ||||||
|  |     @Schema(description = "未成交放入公海天数", example = "2") | ||||||
|  |     @DiffLogField(name = "未成交放入公海天数") | ||||||
|  |     private Integer dealExpireDays; | ||||||
|  |  | ||||||
|  |     @Schema(description = "是否开启提前提醒", example = "true") | ||||||
|  |     @DiffLogField(name = "是否开启提前提醒") | ||||||
|  |     private Boolean notifyEnabled; | ||||||
|  |  | ||||||
|  |     @Schema(description = "提前提醒天数", example = "2") | ||||||
|  |     @DiffLogField(name = "提前提醒天数") | ||||||
|  |     private Integer notifyDays; | ||||||
|  |  | ||||||
|     @AssertTrue(message = "未成交放入公海天数不能为空") |     @AssertTrue(message = "未成交放入公海天数不能为空") | ||||||
|     @JsonIgnore |     @JsonIgnore | ||||||
|  | |||||||
| @ -2,7 +2,6 @@ package cn.iocoder.yudao.module.crm.convert.customer; | |||||||
|  |  | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
| import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigCreateReqVO; |  | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigRespVO; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||||||
| @ -24,8 +23,6 @@ public interface CrmCustomerLimitConfigConvert { | |||||||
|  |  | ||||||
|     CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); |     CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class); | ||||||
|  |  | ||||||
|     CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigCreateReqVO bean); |  | ||||||
|  |  | ||||||
|     CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); |     CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean); | ||||||
|  |  | ||||||
|     CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); |     CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean); | ||||||
|  | |||||||
| @ -2,14 +2,19 @@ package cn.iocoder.yudao.module.crm.service.customer; | |||||||
|  |  | ||||||
| import cn.hutool.core.lang.Assert; | import cn.hutool.core.lang.Assert; | ||||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||||
|  | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigPageReqVO; | ||||||
| import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig.CrmCustomerLimitConfigSaveReqVO; | ||||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerLimitConfigConvert; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerLimitConfigDO; | ||||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerLimitConfigMapper; | ||||||
|  | import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum; | ||||||
| import cn.iocoder.yudao.module.system.api.dept.DeptApi; | import cn.iocoder.yudao.module.system.api.dept.DeptApi; | ||||||
| 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 com.mzt.logapi.context.LogRecordContext; | ||||||
|  | import com.mzt.logapi.service.impl.DiffParseFunction; | ||||||
|  | import com.mzt.logapi.starter.annotation.LogRecord; | ||||||
| import jakarta.annotation.Resource; | import jakarta.annotation.Resource; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.validation.annotation.Validated; | import org.springframework.validation.annotation.Validated; | ||||||
| @ -19,6 +24,7 @@ import java.util.List; | |||||||
|  |  | ||||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||||
| import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; | import static cn.iocoder.yudao.module.crm.enums.ErrorCodeConstants.CUSTOMER_LIMIT_CONFIG_NOT_EXISTS; | ||||||
|  | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 客户限制配置 Service 实现类 |  * 客户限制配置 Service 实现类 | ||||||
| @ -38,34 +44,44 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | |||||||
|     private AdminUserApi adminUserApi; |     private AdminUserApi adminUserApi; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     // TODO @puhui999:操作日志 |     @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUB_TYPE, bizNo = "{{#limitId}}", success = CRM_CUSTOMER_LIMIT_CONFIG_CREATE_SUCCESS) | ||||||
|     public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { |     public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) { | ||||||
|         validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); |         validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds()); | ||||||
|         // 插入 |         // 插入 | ||||||
|         CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); |         CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO); | ||||||
|         customerLimitConfigMapper.insert(customerLimitConfig); |         customerLimitConfigMapper.insert(customerLimitConfig); | ||||||
|  |  | ||||||
|  |         // 记录操作日志上下文 | ||||||
|  |         LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(customerLimitConfig.getType())); | ||||||
|  |         LogRecordContext.putVariable("limitId", customerLimitConfig.getId()); | ||||||
|         // 返回 |         // 返回 | ||||||
|         return customerLimitConfig.getId(); |         return customerLimitConfig.getId(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     // TODO @puhui999:操作日志 |     @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUB_TYPE, bizNo = "{{#updateReqVO.id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_UPDATE_SUCCESS) | ||||||
|     public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { |     public void updateCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO updateReqVO) { | ||||||
|         // 校验存在 |         // 校验存在 | ||||||
|         validateCustomerLimitConfigExists(updateReqVO.getId()); |         CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId()); | ||||||
|         validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); |         validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds()); | ||||||
|         // 更新 |         // 更新 | ||||||
|         CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO); |         CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO); | ||||||
|         customerLimitConfigMapper.updateById(updateObj); |         customerLimitConfigMapper.updateById(updateObj); | ||||||
|  |  | ||||||
|  |         // 记录操作日志上下文 | ||||||
|  |         LogRecordContext.putVariable(DiffParseFunction.OLD_OBJECT, BeanUtils.toBean(oldLimitConfig, CrmCustomerLimitConfigSaveReqVO.class)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     // TODO @puhui999:操作日志 |     @LogRecord(type = CRM_CUSTOMER_LIMIT_CONFIG_TYPE, subType = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUB_TYPE, bizNo = "{{#id}}", success = CRM_CUSTOMER_LIMIT_CONFIG_DELETE_SUCCESS) | ||||||
|     public void deleteCustomerLimitConfig(Long id) { |     public void deleteCustomerLimitConfig(Long id) { | ||||||
|         // 校验存在 |         // 校验存在 | ||||||
|         validateCustomerLimitConfigExists(id); |         CrmCustomerLimitConfigDO limitConfigDO = validateCustomerLimitConfigExists(id); | ||||||
|         // 删除 |         // 删除 | ||||||
|         customerLimitConfigMapper.deleteById(id); |         customerLimitConfigMapper.deleteById(id); | ||||||
|  |  | ||||||
|  |         // 记录操作日志上下文 | ||||||
|  |         LogRecordContext.putVariable("limitType", CrmCustomerLimitConfigTypeEnum.getNameByType(limitConfigDO.getType())); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
| @ -78,10 +94,12 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig | |||||||
|         return customerLimitConfigMapper.selectPage(pageReqVO); |         return customerLimitConfigMapper.selectPage(pageReqVO); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     private void validateCustomerLimitConfigExists(Long id) { |     private CrmCustomerLimitConfigDO validateCustomerLimitConfigExists(Long id) { | ||||||
|         if (customerLimitConfigMapper.selectById(id) == null) { |         CrmCustomerLimitConfigDO limitConfigDO = customerLimitConfigMapper.selectById(id); | ||||||
|  |         if (limitConfigDO == null) { | ||||||
|             throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); |             throw exception(CUSTOMER_LIMIT_CONFIG_NOT_EXISTS); | ||||||
|         } |         } | ||||||
|  |         return limitConfigDO; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     /** |     /** | ||||||
|  | |||||||
| @ -5,12 +5,16 @@ import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCu | |||||||
| import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | import cn.iocoder.yudao.module.crm.convert.customer.CrmCustomerConvert; | ||||||
| import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO; | ||||||
| import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; | import cn.iocoder.yudao.module.crm.dal.mysql.customer.CrmCustomerPoolConfigMapper; | ||||||
|  | import com.mzt.logapi.context.LogRecordContext; | ||||||
|  | import com.mzt.logapi.starter.annotation.LogRecord; | ||||||
|  | import jakarta.annotation.Resource; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.validation.annotation.Validated; | import org.springframework.validation.annotation.Validated; | ||||||
|  |  | ||||||
| import jakarta.annotation.Resource; |  | ||||||
| import java.util.Objects; | import java.util.Objects; | ||||||
|  |  | ||||||
|  | import static cn.iocoder.yudao.module.crm.enums.LogRecordConstants.*; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 客户公海配置 Service 实现类 |  * 客户公海配置 Service 实现类 | ||||||
|  * |  * | ||||||
| @ -19,6 +23,7 @@ import java.util.Objects; | |||||||
| @Service | @Service | ||||||
| @Validated | @Validated | ||||||
| public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { | public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigService { | ||||||
|  |  | ||||||
|     @Resource |     @Resource | ||||||
|     private CrmCustomerPoolConfigMapper customerPoolConfigMapper; |     private CrmCustomerPoolConfigMapper customerPoolConfigMapper; | ||||||
|  |  | ||||||
| @ -38,16 +43,23 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe | |||||||
|      * @param saveReqVO 更新信息 |      * @param saveReqVO 更新信息 | ||||||
|      */ |      */ | ||||||
|     @Override |     @Override | ||||||
|     // TODO @puhui999:操作日志 |     @LogRecord(type = CRM_CUSTOMER_POOL_CONFIG_TYPE, subType = CRM_CUSTOMER_POOL_CONFIG_SUB_TYPE, bizNo = "{{#poolConfigId}}", success = CRM_CUSTOMER_POOL_CONFIG_SUCCESS) | ||||||
|     public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { |     public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) { | ||||||
|         // 存在,则进行更新 |         // 存在,则进行更新 | ||||||
|         CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); |         CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig(); | ||||||
|  |         CrmCustomerPoolConfigDO poolConfig = CrmCustomerConvert.INSTANCE.convert(saveReqVO); | ||||||
|         if (Objects.nonNull(dbConfig)) { |         if (Objects.nonNull(dbConfig)) { | ||||||
|             customerPoolConfigMapper.updateById(CrmCustomerConvert.INSTANCE.convert(saveReqVO).setId(dbConfig.getId())); |             customerPoolConfigMapper.updateById(poolConfig.setId(dbConfig.getId())); | ||||||
|  |             // 记录操作日志上下文 | ||||||
|  |             LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.TRUE); | ||||||
|  |             LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); | ||||||
|             return; |             return; | ||||||
|         } |         } | ||||||
|         // 不存在,则进行插入 |         // 不存在,则进行插入 | ||||||
|         customerPoolConfigMapper.insert(CrmCustomerConvert.INSTANCE.convert(saveReqVO)); |         customerPoolConfigMapper.insert(poolConfig); | ||||||
|  |         // 记录操作日志上下文 | ||||||
|  |         LogRecordContext.putVariable("isPoolConfigUpdate", Boolean.FALSE); | ||||||
|  |         LogRecordContext.putVariable("poolConfigId", poolConfig.getId()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 puhui999
					puhui999