操作日志字段解析方法调整

This commit is contained in:
puhui999 2024-01-13 22:29:05 +08:00
parent 1b87b8a42f
commit eaa8e4be96
25 changed files with 289 additions and 108 deletions

View File

@ -28,13 +28,6 @@
<artifactId>spring-boot-starter-validation</artifactId> <artifactId>spring-boot-starter-validation</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- TODO @puhui999api 之间不直接引入哈然后logrecord function 在微服务下,这么跑会高不起来,所以每个服务自己写 function -->
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-api</artifactId>
<version>${revision}</version>
<optional>true</optional>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -1,8 +1,5 @@
package cn.iocoder.yudao.module.crm.enums; package cn.iocoder.yudao.module.crm.enums;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CONTRACT_BY_ID;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_ADMIN_USER_BY_ID;
/** /**
* CRM 操作日志枚举 * CRM 操作日志枚举
* 目的统一管理也减少 Service 里各种复杂字符串 * 目的统一管理也减少 Service 里各种复杂字符串
@ -25,7 +22,7 @@ public interface LogRecordConstants {
String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户"; String CRM_CUSTOMER_DELETE_SUB_TYPE = "删除客户";
String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】"; String CRM_CUSTOMER_DELETE_SUCCESS = "删除了客户【{{#customerName}}】";
String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户"; String CRM_CUSTOMER_TRANSFER_SUB_TYPE = "转移客户";
String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#customer.name}}】的负责人从【{" + GET_ADMIN_USER_BY_ID + "{#customer.ownerUserId}}】变更为了【{" + GET_ADMIN_USER_BY_ID + "{#reqVO.newOwnerUserId}}】"; String CRM_CUSTOMER_TRANSFER_SUCCESS = "将客户【{{#customer.name}}】的负责人从【{getAdminUserById{#customer.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#customer.lockStatus ? '解锁客户' : '锁定客户'}}"; String CRM_CUSTOMER_LOCK_SUB_TYPE = "{{#customer.lockStatus ? '解锁客户' : '锁定客户'}}";
String CRM_CUSTOMER_LOCK_SUCCESS = "{{#customer.lockStatus ? '将客户【' + #customer.name + '】解锁' : '将客户【' + #customer.name + '】锁定'}}"; String CRM_CUSTOMER_LOCK_SUCCESS = "{{#customer.lockStatus ? '将客户【' + #customer.name + '】解锁' : '将客户【' + #customer.name + '】锁定'}}";
String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海"; String CRM_CUSTOMER_POOL_SUB_TYPE = "客户放入公海";
@ -59,7 +56,7 @@ public interface LogRecordConstants {
String CRM_CONTACT_DELETE_SUB_TYPE = "删除联系人"; String CRM_CONTACT_DELETE_SUB_TYPE = "删除联系人";
String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】"; String CRM_CONTACT_DELETE_SUCCESS = "删除了联系人【{{#contactName}}】";
String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人"; String CRM_CONTACT_TRANSFER_SUB_TYPE = "转移联系人";
String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{" + GET_ADMIN_USER_BY_ID + "{#contact.ownerUserId}}】变更为了【{" + GET_ADMIN_USER_BY_ID + "{#reqVO.newOwnerUserId}}】"; String CRM_CONTACT_TRANSFER_SUCCESS = "将联系人【{{#contact.name}}】的负责人从【{getAdminUserById{#contact.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
// ======================= CRM_BUSINESS 商机 ======================= // ======================= CRM_BUSINESS 商机 =======================
@ -71,7 +68,7 @@ public interface LogRecordConstants {
String CRM_BUSINESS_DELETE_SUB_TYPE = "删除商机"; String CRM_BUSINESS_DELETE_SUB_TYPE = "删除商机";
String CRM_BUSINESS_DELETE_SUCCESS = "删除了商机【{{#businessName}}】"; String CRM_BUSINESS_DELETE_SUCCESS = "删除了商机【{{#businessName}}】";
String CRM_BUSINESS_TRANSFER_SUB_TYPE = "转移商机"; String CRM_BUSINESS_TRANSFER_SUB_TYPE = "转移商机";
String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{" + GET_ADMIN_USER_BY_ID + "{#business.ownerUserId}}】变更为了【{" + GET_ADMIN_USER_BY_ID + "{#reqVO.newOwnerUserId}}】"; String CRM_BUSINESS_TRANSFER_SUCCESS = "将商机【{{#business.name}}】的负责人从【{getAdminUserById{#business.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
// ======================= CRM_CONTRACT 合同 ======================= // ======================= CRM_CONTRACT 合同 =======================
@ -83,7 +80,7 @@ public interface LogRecordConstants {
String CRM_CONTRACT_DELETE_SUB_TYPE = "删除合同"; String CRM_CONTRACT_DELETE_SUB_TYPE = "删除合同";
String CRM_CONTRACT_DELETE_SUCCESS = "删除了合同【{{#contractName}}】"; String CRM_CONTRACT_DELETE_SUCCESS = "删除了合同【{{#contractName}}】";
String CRM_CONTRACT_TRANSFER_SUB_TYPE = "转移合同"; String CRM_CONTRACT_TRANSFER_SUB_TYPE = "转移合同";
String CRM_CONTRACT_TRANSFER_SUCCESS = "将合同【{{#contract.name}}】的负责人从【{" + GET_ADMIN_USER_BY_ID + "{#contract.ownerUserId}}】变更为了【{" + GET_ADMIN_USER_BY_ID + "{#reqVO.newOwnerUserId}}】"; String CRM_CONTRACT_TRANSFER_SUCCESS = "将合同【{{#contract.name}}】的负责人从【{getAdminUserById{#contract.ownerUserId}}】变更为了【{getAdminUserById{#reqVO.newOwnerUserId}}】";
// ======================= CRM_PRODUCT 产品 ======================= // ======================= CRM_PRODUCT 产品 =======================
@ -109,20 +106,20 @@ public interface LogRecordConstants {
String CRM_RECEIVABLE_TYPE = "CRM 回款"; String CRM_RECEIVABLE_TYPE = "CRM 回款";
String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款"; String CRM_RECEIVABLE_CREATE_SUB_TYPE = "创建回款";
String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{" + GET_CONTRACT_BY_ID + "{#receivable.contractId}}】的第【{{#receivable.period}}】期回款"; String CRM_RECEIVABLE_CREATE_SUCCESS = "创建了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款";
String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款"; String CRM_RECEIVABLE_UPDATE_SUB_TYPE = "更新回款";
String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{" + GET_CONTRACT_BY_ID + "{#receivable.contractId}}】的第【{{#receivable.period}}】期回款: {_DIFF{#updateReqVO}}"; String CRM_RECEIVABLE_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款: {_DIFF{#updateReqVO}}";
String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款"; String CRM_RECEIVABLE_DELETE_SUB_TYPE = "删除回款";
String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{" + GET_CONTRACT_BY_ID + "{#receivable.contractId}}】的第【{{#receivable.period}}】期回款"; String CRM_RECEIVABLE_DELETE_SUCCESS = "删除了合同【{getContractById{#receivable.contractId}}】的第【{{#receivable.period}}】期回款";
// ======================= CRM_RECEIVABLE_PLAN 回款计划 ======================= // ======================= CRM_RECEIVABLE_PLAN 回款计划 =======================
String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划"; String CRM_RECEIVABLE_PLAN_TYPE = "CRM 回款计划";
String CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE = "创建回款计划"; String CRM_RECEIVABLE_PLAN_CREATE_SUB_TYPE = "创建回款计划";
String CRM_RECEIVABLE_PLAN_CREATE_SUCCESS = "创建了合同【{" + GET_CONTRACT_BY_ID + "{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划"; String CRM_RECEIVABLE_PLAN_CREATE_SUCCESS = "创建了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划";
String CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE = "更新回款计划"; String CRM_RECEIVABLE_PLAN_UPDATE_SUB_TYPE = "更新回款计划";
String CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS = "更新了合同【{" + GET_CONTRACT_BY_ID + "{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划: {_DIFF{#updateReqVO}}"; String CRM_RECEIVABLE_PLAN_UPDATE_SUCCESS = "更新了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划: {_DIFF{#updateReqVO}}";
String CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE = "删除回款计划"; String CRM_RECEIVABLE_PLAN_DELETE_SUB_TYPE = "删除回款计划";
String CRM_RECEIVABLE_PLAN_DELETE_SUCCESS = "删除了合同【{" + GET_CONTRACT_BY_ID + "{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划"; String CRM_RECEIVABLE_PLAN_DELETE_SUCCESS = "删除了合同【{getContractById{#receivablePlan.contractId}}】的第【{{#receivablePlan.period}}】期回款计划";
} }

View File

@ -1,19 +0,0 @@
package cn.iocoder.yudao.module.crm.enums.operatelog;
/**
* functionName 常量枚举
* 方便别的模块调用
*
* @author HUIHUI
*/
// TODO @puhui999这个枚举还是放在对应的 Function 里好主要考虑 Function 实现可以更近一点哈
public interface CrmParseFunctionNameConstants {
String GET_CONTACT_BY_ID = "getContactById"; // 获取联系人信息
String GET_CUSTOMER_BY_ID = "getCustomerById"; // 获取客户信息
String GET_CUSTOMER_INDUSTRY = "getCustomerIndustry"; // 获取客户行业信息
String GET_CUSTOMER_LEVEL = "getCustomerLevel"; // 获取客户级别
String GET_CUSTOMER_SOURCE = "getCustomerSource"; // 获取客户来源
String GET_CONTRACT_BY_ID = "getContractById"; // 获取合同信息
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.business;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
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.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.business.vo.business.*; import cn.iocoder.yudao.module.crm.controller.admin.business.vo.business.*;
@ -85,6 +86,14 @@ public class CrmBusinessController {
return success(CrmBusinessConvert.INSTANCE.convert(business)); return success(CrmBusinessConvert.INSTANCE.convert(business));
} }
@GetMapping("/list-by-ids")
@Operation(summary = "获得商机列表")
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
@PreAuthorize("@ss.hasPermission('crm:business:query')")
public CommonResult<List<CrmBusinessRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) {
return success(BeanUtils.toBean(businessService.getBusinessList(ids, getLoginUserId()), CrmBusinessRespVO.class));
}
@GetMapping("/page") @GetMapping("/page")
@Operation(summary = "获得商机分页") @Operation(summary = "获得商机分页")
@PreAuthorize("@ss.hasPermission('crm:business:query')") @PreAuthorize("@ss.hasPermission('crm:business:query')")

View File

@ -113,6 +113,14 @@ public class CrmContactController {
return success(CrmContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList)); return success(CrmContactConvert.INSTANCE.convert(contact, userMap, customerList, parentContactList));
} }
@GetMapping("/list-by-ids")
@Operation(summary = "获得联系人列表")
@Parameter(name = "ids", description = "编号", required = true, example = "[1024]")
@PreAuthorize("@ss.hasPermission('crm:contact:query')")
public CommonResult<List<CrmContactRespVO>> getContactListByIds(@RequestParam("ids") List<Long> ids) {
return success(BeanUtils.toBean(contactService.getContactList(ids, getLoginUserId()), CrmContactRespVO.class));
}
@GetMapping("/simple-all-list") @GetMapping("/simple-all-list")
@Operation(summary = "获得联系人的精简列表") @Operation(summary = "获得联系人的精简列表")
@PreAuthorize("@ss.hasPermission('crm:contact:query')") @PreAuthorize("@ss.hasPermission('crm:contact:query')")

View File

@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.crm.controller.admin.contact.vo;
import cn.iocoder.yudao.framework.common.validation.Mobile; import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone; import cn.iocoder.yudao.framework.common.validation.Telephone;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.*;
import com.mzt.logapi.starter.annotation.DiffLogField; 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.Email; import jakarta.validation.constraints.Email;
@ -13,9 +14,6 @@ import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CONTACT_BY_ID;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_BY_ID;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.*;
@Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO") @Schema(description = "管理后台 - CRM 联系人创建/更新 Request VO")
@Data @Data
@ -30,11 +28,11 @@ public class CrmContactSaveReqVO {
private String name; private String name;
@Schema(description = "客户编号", example = "10795") @Schema(description = "客户编号", example = "10795")
@DiffLogField(name = "姓名", function = GET_CUSTOMER_BY_ID) @DiffLogField(name = "姓名", function = CrmCustomerParseFunction.NAME)
private Long customerId; private Long customerId;
@Schema(description = "性别") @Schema(description = "性别")
@DiffLogField(name = "性别", function = GET_SEX) @DiffLogField(name = "性别", function = SysSexParseFunction.NAME)
private Integer sex; private Integer sex;
@Schema(description = "职位") @Schema(description = "职位")
@ -42,11 +40,11 @@ public class CrmContactSaveReqVO {
private String post; private String post;
@Schema(description = "是否关键决策人") @Schema(description = "是否关键决策人")
@DiffLogField(name = "关键决策人", function = GET_BOOLEAN) @DiffLogField(name = "关键决策人", function = SysBooleanParseFunction.NAME)
private Boolean master; private Boolean master;
@Schema(description = "直属上级", example = "23457") @Schema(description = "直属上级", example = "23457")
@DiffLogField(name = "直属上级", function = GET_CONTACT_BY_ID) @DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME)
private Long parentId; private Long parentId;
@Schema(description = "手机号", example = "1387171766") @Schema(description = "手机号", example = "1387171766")
@ -73,7 +71,7 @@ public class CrmContactSaveReqVO {
private String email; private String email;
@Schema(description = "地区编号", example = "20158") @Schema(description = "地区编号", example = "20158")
@DiffLogField(name = "所在地", function = GET_AREA) @DiffLogField(name = "所在地", function = SysAreaParseFunction.NAME)
private Integer areaId; private Integer areaId;
@Schema(description = "地址") @Schema(description = "地址")
@ -86,7 +84,7 @@ public class CrmContactSaveReqVO {
@Schema(description = "负责人用户编号", example = "14334") @Schema(description = "负责人用户编号", example = "14334")
@NotNull(message = "负责人不能为空") @NotNull(message = "负责人不能为空")
@DiffLogField(name = "负责人", function = GET_ADMIN_USER_BY_ID) @DiffLogField(name = "负责人", function = SysAdminUserParseFunction.NAME)
private Long ownerUserId; private Long ownerUserId;
@Schema(description = "最后跟进时间") @Schema(description = "最后跟进时间")

View File

@ -5,6 +5,10 @@ import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone; import cn.iocoder.yudao.framework.common.validation.Telephone;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum; import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerIndustryParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerLevelParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmCustomerSourceParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAreaParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField; 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.Email; import jakarta.validation.constraints.Email;
@ -17,8 +21,6 @@ import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.*;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_AREA;
@Schema(description = "管理后台 - CRM 客户新增/修改 Request VO") @Schema(description = "管理后台 - CRM 客户新增/修改 Request VO")
@Data @Data
@ -33,17 +35,17 @@ public class CrmCustomerSaveReqVO {
private String name; private String name;
@Schema(description = "所属行业", example = "1") @Schema(description = "所属行业", example = "1")
@DiffLogField(name = "所属行业", function = GET_CUSTOMER_INDUSTRY) @DiffLogField(name = "所属行业", function = CrmCustomerIndustryParseFunction.NAME)
@DictFormat(CRM_CUSTOMER_INDUSTRY) @DictFormat(CRM_CUSTOMER_INDUSTRY)
private Integer industryId; private Integer industryId;
@Schema(description = "客户等级", example = "2") @Schema(description = "客户等级", example = "2")
@DiffLogField(name = "客户等级", function = GET_CUSTOMER_LEVEL) @DiffLogField(name = "客户等级", function = CrmCustomerLevelParseFunction.NAME)
@InEnum(CrmCustomerLevelEnum.class) @InEnum(CrmCustomerLevelEnum.class)
private Integer level; private Integer level;
@Schema(description = "客户来源", example = "3") @Schema(description = "客户来源", example = "3")
@DiffLogField(name = "客户来源", function = GET_CUSTOMER_SOURCE) @DiffLogField(name = "客户来源", function = CrmCustomerSourceParseFunction.NAME)
private Integer source; private Integer source;
@Schema(description = "手机", example = "18000000000") @Schema(description = "手机", example = "18000000000")
@ -86,7 +88,7 @@ public class CrmCustomerSaveReqVO {
private String remark; private String remark;
@Schema(description = "地区编号", example = "20158") @Schema(description = "地区编号", example = "20158")
@DiffLogField(name = "地区编号", function = GET_AREA) @DiffLogField(name = "地区编号", function = SysAreaParseFunction.NAME)
private Integer areaId; private Integer areaId;
@Schema(description = "详细地址", example = "北京市海淀区") @Schema(description = "详细地址", example = "北京市海淀区")

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig; package cn.iocoder.yudao.module.crm.controller.admin.customer.vo.limitconfig;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysAdminUserParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.SysDeptParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField; 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.NotNull; import jakarta.validation.constraints.NotNull;
@ -7,9 +9,6 @@ import lombok.Data;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_ADMIN_USER_BY_ID;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_DEPT_BY_ID;
@Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO") @Schema(description = "管理后台 - 客户限制配置创建/更新 Request VO")
@Data @Data
public class CrmCustomerLimitConfigSaveReqVO { public class CrmCustomerLimitConfigSaveReqVO {
@ -23,11 +22,11 @@ public class CrmCustomerLimitConfigSaveReqVO {
private Integer type; private Integer type;
@Schema(description = "规则适用人群") @Schema(description = "规则适用人群")
@DiffLogField(name = "规则适用人群", function = GET_ADMIN_USER_BY_ID) @DiffLogField(name = "规则适用人群", function = SysAdminUserParseFunction.NAME)
private List<Long> userIds; private List<Long> userIds;
@Schema(description = "规则适用部门") @Schema(description = "规则适用部门")
@DiffLogField(name = "规则适用部门", function = GET_DEPT_BY_ID) @DiffLogField(name = "规则适用部门", function = SysDeptParseFunction.NAME)
private List<Long> deptIds; private List<Long> deptIds;
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384") @Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")

View File

@ -8,8 +8,6 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CONTACT_BY_ID;
/** /**
* CRM 联系人的 {@link IParseFunction} 实现类 * CRM 联系人的 {@link IParseFunction} 实现类
* *
@ -19,6 +17,8 @@ import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameC
@Slf4j @Slf4j
public class CrmContactParseFunction implements IParseFunction { public class CrmContactParseFunction implements IParseFunction {
public static final String NAME = "getContactById";
@Resource @Resource
private CrmContactService contactService; private CrmContactService contactService;
@ -29,7 +29,7 @@ public class CrmContactParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_CONTACT_BY_ID; return NAME;
} }
@Override @Override

View File

@ -8,8 +8,6 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CONTRACT_BY_ID;
/** /**
* CRM 合同的 {@link IParseFunction} 实现类 * CRM 合同的 {@link IParseFunction} 实现类
* *
@ -19,6 +17,8 @@ import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameC
@Slf4j @Slf4j
public class CrmContractParseFunction implements IParseFunction { public class CrmContractParseFunction implements IParseFunction {
public static final String NAME = "getContractById";
@Resource @Resource
private CrmContractService contractService; private CrmContractService contractService;
@ -29,7 +29,7 @@ public class CrmContractParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_CONTRACT_BY_ID; return NAME;
} }
@Override @Override

View File

@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY; import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_INDUSTRY;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_INDUSTRY;
/** /**
* 行业的 {@link IParseFunction} 实现类 * 行业的 {@link IParseFunction} 实现类
@ -18,6 +17,8 @@ import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameC
@Slf4j @Slf4j
public class CrmCustomerIndustryParseFunction implements IParseFunction { public class CrmCustomerIndustryParseFunction implements IParseFunction {
public static final String NAME = "getCustomerIndustry";
@Override @Override
public boolean executeBefore() { public boolean executeBefore() {
return true; // 先转换值后对比 return true; // 先转换值后对比
@ -25,7 +26,7 @@ public class CrmCustomerIndustryParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_CUSTOMER_INDUSTRY; return NAME;
} }
@Override @Override

View File

@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL; import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_LEVEL;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_LEVEL;
/** /**
* 客户等级的 {@link IParseFunction} 实现类 * 客户等级的 {@link IParseFunction} 实现类
@ -18,6 +17,8 @@ import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameC
@Slf4j @Slf4j
public class CrmCustomerLevelParseFunction implements IParseFunction { public class CrmCustomerLevelParseFunction implements IParseFunction {
public static final String NAME = "getCustomerLevel";
@Override @Override
public boolean executeBefore() { public boolean executeBefore() {
return true; // 先转换值后对比 return true; // 先转换值后对比
@ -25,7 +26,7 @@ public class CrmCustomerLevelParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_CUSTOMER_LEVEL; return NAME;
} }
@Override @Override

View File

@ -8,8 +8,6 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_BY_ID;
/** /**
* CRM 客户的 {@link IParseFunction} 实现类 * CRM 客户的 {@link IParseFunction} 实现类
* *
@ -19,6 +17,8 @@ import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameC
@Slf4j @Slf4j
public class CrmCustomerParseFunction implements IParseFunction { public class CrmCustomerParseFunction implements IParseFunction {
public static final String NAME = "getCustomerById";
@Resource @Resource
private CrmCustomerService customerService; private CrmCustomerService customerService;
@ -29,7 +29,7 @@ public class CrmCustomerParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_CUSTOMER_BY_ID; return NAME;
} }
@Override @Override

View File

@ -7,7 +7,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE; import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_SOURCE;
import static cn.iocoder.yudao.module.crm.enums.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_SOURCE;
/** /**
* CRM 客户来源的 {@link IParseFunction} 实现类 * CRM 客户来源的 {@link IParseFunction} 实现类
@ -27,7 +26,7 @@ public class CrmCustomerSourceParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_CUSTOMER_SOURCE; return NAME;
} }
@Override @Override

View File

@ -0,0 +1,50 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import com.mzt.logapi.service.IParseFunction;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 管理员名字的 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Slf4j
@Component
public class SysAdminUserParseFunction implements IParseFunction {
public static final String NAME = "getAdminUserById";
@Resource
private AdminUserApi adminUserApi;
@Override
public String functionName() {
return NAME;
}
@Override
public String apply(Object value) {
if (StrUtil.isEmptyIfStr(value)) {
return "";
}
// 获取用户信息
AdminUserRespDTO user = adminUserApi.getUser(Long.parseLong(value.toString()));
if (user == null) {
log.warn("[apply][获取用户{{}}为空", value);
return "";
}
// 返回格式 芋道源码(13888888888)
String nickname = user.getNickname();
if (StrUtil.isEmpty(user.getMobile())) {
return nickname;
}
return StrUtil.format("{}({})", nickname, user.getMobile());
}
}

View File

@ -0,0 +1,38 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 地名的 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Slf4j
@Component
public class SysAreaParseFunction implements IParseFunction {
public static final String NAME = "getArea";
@Override
public boolean executeBefore() {
return true; // 先转换值后对比
}
@Override
public String functionName() {
return NAME;
}
@Override
public String apply(Object value) {
if (StrUtil.isEmptyIfStr(value)) {
return "";
}
return AreaUtils.format(Integer.parseInt(value.toString()));
}
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.module.infra.enums.DictTypeConstants;
import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 是否类型的 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Component
@Slf4j
public class SysBooleanParseFunction implements IParseFunction {
public static final String NAME = "getBoolean";
@Override
public boolean executeBefore() {
return true; // 先转换值后对比
}
@Override
public String functionName() {
return NAME;
}
@Override
public String apply(Object value) {
if (StrUtil.isEmptyIfStr(value)) {
return "";
}
return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.BOOLEAN_STRING, value.toString());
}
}

View File

@ -0,0 +1,45 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import com.mzt.logapi.service.IParseFunction;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 管理员名字的 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Slf4j
@Component
public class SysDeptParseFunction implements IParseFunction {
public static final String NAME = "getDeptById";
@Resource
private DeptApi deptApi;
@Override
public String functionName() {
return NAME;
}
@Override
public String apply(Object value) {
if (StrUtil.isEmptyIfStr(value)) {
return "";
}
// 获取部门信息
DeptRespDTO dept = deptApi.getDept(Long.parseLong(value.toString()));
if (dept == null) {
log.warn("[apply][获取部门{{}}为空", value);
return "";
}
return dept.getName();
}
}

View File

@ -0,0 +1,39 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.module.system.enums.DictTypeConstants;
import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* 行业的 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Component
@Slf4j
public class SysSexParseFunction implements IParseFunction {
public static final String NAME = "getSex";
@Override
public boolean executeBefore() {
return true; // 先转换值后对比
}
@Override
public String functionName() {
return NAME;
}
@Override
public String apply(Object value) {
if (StrUtil.isEmptyIfStr(value)) {
return "";
}
return DictFrameworkUtils.getDictDataLabel(DictTypeConstants.USER_SEX, value.toString());
}
}

View File

@ -1,18 +0,0 @@
package cn.iocoder.yudao.module.system.enums.operatelog;
/**
* functionName 常量枚举
* 方便别的模块调用
*
* @author HUIHUI
*/
// TODO @puhui999这个枚举还是放在对应的 Function 里好主要考虑 Function 实现可以更近一点哈
public interface SysParseFunctionNameConstants {
String GET_ADMIN_USER_BY_ID = "getAdminUserById"; // 获取用户信息
String GET_DEPT_BY_ID = "getDeptById"; // 获取部门信息
String GET_AREA = "getArea"; // 获取区域信息
String GET_SEX = "getSex"; // 获取性别
String GET_BOOLEAN = "getBoolean"; // 获取是否
}

View File

@ -8,8 +8,6 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_ADMIN_USER_BY_ID;
/** /**
* 管理员名字的 {@link IParseFunction} 实现类 * 管理员名字的 {@link IParseFunction} 实现类
* *
@ -19,12 +17,14 @@ import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNa
@Component @Component
public class AdminUserParseFunction implements IParseFunction { public class AdminUserParseFunction implements IParseFunction {
public static final String NAME = "getAdminUserById";
@Resource @Resource
private AdminUserApi adminUserApi; private AdminUserApi adminUserApi;
@Override @Override
public String functionName() { public String functionName() {
return GET_ADMIN_USER_BY_ID; return NAME;
} }
@Override @Override

View File

@ -6,8 +6,6 @@ import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_AREA;
/** /**
* 地名的 {@link IParseFunction} 实现类 * 地名的 {@link IParseFunction} 实现类
* *
@ -17,6 +15,8 @@ import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNa
@Component @Component
public class AreaParseFunction implements IParseFunction { public class AreaParseFunction implements IParseFunction {
public static final String NAME = "getArea";
@Override @Override
public boolean executeBefore() { public boolean executeBefore() {
return true; // 先转换值后对比 return true; // 先转换值后对比
@ -24,7 +24,7 @@ public class AreaParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_AREA; return NAME;
} }
@Override @Override

View File

@ -7,8 +7,6 @@ import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_BOOLEAN;
/** /**
* 是否类型的 {@link IParseFunction} 实现类 * 是否类型的 {@link IParseFunction} 实现类
* *
@ -18,6 +16,8 @@ import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNa
@Slf4j @Slf4j
public class BooleanParseFunction implements IParseFunction { public class BooleanParseFunction implements IParseFunction {
public static final String NAME = "getBoolean";
@Override @Override
public boolean executeBefore() { public boolean executeBefore() {
return true; // 先转换值后对比 return true; // 先转换值后对比
@ -25,7 +25,7 @@ public class BooleanParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_BOOLEAN; return NAME;
} }
@Override @Override

View File

@ -8,8 +8,6 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_DEPT_BY_ID;
/** /**
* 管理员名字的 {@link IParseFunction} 实现类 * 管理员名字的 {@link IParseFunction} 实现类
* *
@ -19,12 +17,14 @@ import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNa
@Component @Component
public class DeptParseFunction implements IParseFunction { public class DeptParseFunction implements IParseFunction {
public static final String NAME = "getDeptById";
@Resource @Resource
private DeptApi deptApi; private DeptApi deptApi;
@Override @Override
public String functionName() { public String functionName() {
return GET_DEPT_BY_ID; return NAME;
} }
@Override @Override

View File

@ -7,8 +7,6 @@ import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_SEX;
/** /**
* 行业的 {@link IParseFunction} 实现类 * 行业的 {@link IParseFunction} 实现类
* *
@ -18,6 +16,8 @@ import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNa
@Slf4j @Slf4j
public class SexParseFunction implements IParseFunction { public class SexParseFunction implements IParseFunction {
public static final String NAME = "getSex";
@Override @Override
public boolean executeBefore() { public boolean executeBefore() {
return true; // 先转换值后对比 return true; // 先转换值后对比
@ -25,7 +25,7 @@ public class SexParseFunction implements IParseFunction {
@Override @Override
public String functionName() { public String functionName() {
return GET_SEX; return NAME;
} }
@Override @Override