新增 ParseFunctionNameConstants 常量枚举

This commit is contained in:
puhui999 2024-01-10 11:29:29 +08:00
parent 63db275af1
commit 9bba1ce8a4
29 changed files with 161 additions and 157 deletions

View File

@ -122,7 +122,12 @@ public class LocalDateTimeUtils {
return date.with(TemporalAdjusters.lastDayOfMonth()).with(LocalTime.MAX);
}
// TODO @puhui999加下注释哈
/**
* 获取指定日期到现在过了几天如果指定日期在当前日期之后获取结果为负
*
* @param dateTime 日期
* @return 相差天数
*/
public static Long between(LocalDateTime dateTime) {
return LocalDateTimeUtil.between(dateTime, LocalDateTime.now(), ChronoUnit.DAYS);
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.crm.enums.operatelog;
/**
* functionName 常量枚举
* 方便别的模块调用
*
* @author HUIHUI
*/
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"; // 获取客户来源
}

View File

@ -2,7 +2,6 @@ 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.Telephone;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.*;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
@ -14,10 +13,13 @@ 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_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")
@Data
public class CrmContactSaveReqVO {
public class CrmContactSaveReqVO {
@Schema(description = "主键", example = "3167")
private Long id;
@ -28,11 +30,11 @@ public class CrmContactSaveReqVO {
private String name;
@Schema(description = "客户编号", example = "10795")
@DiffLogField(name = "姓名", function = CrmCustomerParseFunction.NAME)
@DiffLogField(name = "姓名", function = GET_CUSTOMER_BY_ID)
private Long customerId;
@Schema(description = "性别")
@DiffLogField(name = "性别", function = CrmSexParseFunction.NAME)
@DiffLogField(name = "性别", function = GET_SEX)
private Integer sex;
@Schema(description = "职位")
@ -40,11 +42,11 @@ public class CrmContactSaveReqVO {
private String post;
@Schema(description = "是否关键决策人")
@DiffLogField(name = "关键决策人", function = CrmBooleanParseFunction.NAME)
@DiffLogField(name = "关键决策人", function = GET_BOOLEAN)
private Boolean master;
@Schema(description = "直属上级", example = "23457")
@DiffLogField(name = "直属上级", function = CrmContactParseFunction.NAME)
@DiffLogField(name = "直属上级", function = GET_CONTACT_BY_ID)
private Long parentId;
@Schema(description = "手机号", example = "1387171766")
@ -71,7 +73,7 @@ public class CrmContactSaveReqVO {
private String email;
@Schema(description = "地区编号", example = "20158")
@DiffLogField(name = "所在地", function = "getAreaById")
@DiffLogField(name = "所在地", function = GET_AREA)
private Integer areaId;
@Schema(description = "地址")
@ -84,7 +86,7 @@ public class CrmContactSaveReqVO {
@Schema(description = "负责人用户编号", example = "14334")
@NotNull(message = "负责人不能为空")
@DiffLogField(name = "负责人", function = CrmSysUserParseFunction.NAME)
@DiffLogField(name = "负责人", function = GET_ADMIN_USER_BY_ID)
private Long ownerUserId;
@Schema(description = "最后跟进时间")

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ObjUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils;
@ -32,6 +34,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
@ -112,32 +115,40 @@ public class CrmCustomerController {
}
// 2. 拼接数据
Map<Long, Long> poolDayMap = getPoolDayMap(pageResult); // 距离进入公海的时间
Map<Long, Long> poolDayMap = null;
if (ObjUtil.notEqual(pageVO.getPool(), Boolean.TRUE)) {
poolDayMap = getPoolDayMap(pageResult.getList()); // 距离进入公海的时间
}
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(
convertSetByFlatMap(pageResult.getList(), user -> Stream.of(Long.parseLong(user.getCreator()), user.getOwnerUserId())));
Map<Long, DeptRespDTO> deptMap = deptApi.getDeptMap(convertSet(userMap.values(), AdminUserRespDTO::getDeptId));
return success(CrmCustomerConvert.INSTANCE.convertPage(pageResult, userMap, deptMap, poolDayMap));
}
// TODO @puhui999加下注释哈
private Map<Long, Long> getPoolDayMap(PageResult<CrmCustomerDO> pageResult) {
Map<Long, Long> poolDayMap = null;
/**
* 获取距离进入公海的时间
*
* @param customerList 客户列表
* @return Map<key 客户编号, value 距离进入公海的时间>
*/
private Map<Long, Long> getPoolDayMap(List<CrmCustomerDO> customerList) {
CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig();
// TODO @puhui999if return 减少括号
if (customerPoolConfig != null && customerPoolConfig.getEnabled()) { // 有公海配置的情况
// TODO @puhui999item 改成 customer 更好容易理解
poolDayMap = convertMap(pageResult.getList(), CrmCustomerDO::getId, item -> {
long dealExpireDay = 0;
if (!item.getDealStatus()) { // 检查是否成交
dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(item.getCreateTime());
}
// TODO @puhui999需要考虑 contactLastTime 为空的情况哈
long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(item.getContactLastTime());
return dealExpireDay == 0 ? contactExpireDay : Math.min(dealExpireDay, contactExpireDay);
});
// TODO @puhui999需要考虑 lock 的情况么
if (customerPoolConfig == null || !customerPoolConfig.getEnabled()) {
return MapUtil.empty();
}
return poolDayMap;
// TODO @puhui999需要考虑 lock 的情况么 回复锁定正常显示距离进入公海的时间有个提示
return convertMap(customerList, CrmCustomerDO::getId, customer -> {
long dealExpireDay = 0;
if (!customer.getDealStatus()) { // 检查是否成交
dealExpireDay = customerPoolConfig.getDealExpireDays() - LocalDateTimeUtils.between(customer.getCreateTime());
}
LocalDateTime lastTime = customer.getContactLastTime() != null ? customer.getContactLastTime() : customer.getCreateTime();
long contactExpireDay = customerPoolConfig.getContactExpireDays() - LocalDateTimeUtils.between(lastTime);
if (contactExpireDay < 0) {
contactExpireDay = 0; // 如果为负的话重置为零
}
return Math.min(dealExpireDay, contactExpireDay);
});
}
@GetMapping(value = "/list-all-simple")

View File

@ -1,9 +1,9 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
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.service.customer.CrmCustomerPoolConfigService;
import io.swagger.v3.oas.annotations.Operation;
@ -30,7 +30,7 @@ public class CrmCustomerPoolConfigController {
@PreAuthorize("@ss.hasPermission('crm:customer-pool-config:query')")
public CommonResult<CrmCustomerPoolConfigRespVO> getCustomerPoolConfig() {
CrmCustomerPoolConfigDO customerPoolConfig = customerPoolConfigService.getCustomerPoolConfig();
return success(CrmCustomerConvert.INSTANCE.convert(customerPoolConfig));
return success(BeanUtils.toBean(customerPoolConfig, CrmCustomerPoolConfigRespVO.class));
}
@PutMapping("/save")

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.crm.controller.admin.customer.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
@ -11,7 +12,7 @@ import java.util.List;
public class CrmCustomerDistributeReqVO {
@Schema(description = "客户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "[1024]")
@NotNull(message = "客户编号不能为空") // TODO @puhui999list @NotEmpty
@NotEmpty(message = "客户编号不能为空")
private List<Long> ids;
@Schema(description = "负责人", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")

View File

@ -5,9 +5,6 @@ import cn.iocoder.yudao.framework.common.validation.Mobile;
import cn.iocoder.yudao.framework.common.validation.Telephone;
import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLevelEnum;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmIndustryParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmLevelParseFunction;
import cn.iocoder.yudao.module.crm.framework.operatelog.core.CrmSourceParseFunction;
import com.mzt.logapi.starter.annotation.DiffLogField;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Email;
@ -20,6 +17,8 @@ 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.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")
@Data
@ -34,17 +33,17 @@ public class CrmCustomerSaveReqVO {
private String name;
@Schema(description = "所属行业", example = "1")
@DiffLogField(name = "所属行业", function = CrmIndustryParseFunction.NAME)
@DiffLogField(name = "所属行业", function = GET_CUSTOMER_INDUSTRY)
@DictFormat(CRM_CUSTOMER_INDUSTRY)
private Integer industryId;
@Schema(description = "客户等级", example = "2")
@DiffLogField(name = "客户等级", function = CrmLevelParseFunction.NAME)
@DiffLogField(name = "客户等级", function = GET_CUSTOMER_LEVEL)
@InEnum(CrmCustomerLevelEnum.class)
private Integer level;
@Schema(description = "客户来源", example = "3")
@DiffLogField(name = "客户来源", function = CrmSourceParseFunction.NAME)
@DiffLogField(name = "客户来源", function = GET_CUSTOMER_SOURCE)
private Integer source;
@Schema(description = "手机", example = "18000000000")
@ -87,7 +86,7 @@ public class CrmCustomerSaveReqVO {
private String remark;
@Schema(description = "地区编号", example = "20158")
@DiffLogField(name = "地区编号", function = "getAreaById")
@DiffLogField(name = "地区编号", function = GET_AREA)
private Integer areaId;
@Schema(description = "详细地址", example = "北京市海淀区")

View File

@ -7,6 +7,9 @@ import lombok.Data;
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")
@Data
public class CrmCustomerLimitConfigSaveReqVO {
@ -19,13 +22,12 @@ public class CrmCustomerLimitConfigSaveReqVO {
@DiffLogField(name = "规则类型")
private Integer type;
// TODO @puhui999可以把 Function 那的 functionName 搞成 NAME 枚举这里直接引用这样后续改动更方便哈
@Schema(description = "规则适用人群")
@DiffLogField(name = "规则适用人群", function = "getAdminUserById")
@DiffLogField(name = "规则适用人群", function = GET_ADMIN_USER_BY_ID)
private List<Long> userIds;
@Schema(description = "规则适用部门")
@DiffLogField(name = "规则适用部门", function = "getDeptById")
@DiffLogField(name = "规则适用部门", function = GET_DEPT_BY_ID)
private List<Long> deptIds;
@Schema(description = "数量上限", requiredMode = Schema.RequiredMode.REQUIRED, example = "28384")

View File

@ -3,12 +3,8 @@ package cn.iocoder.yudao.module.crm.convert.customer;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerSaveReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.CrmCustomerTransferReqVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigRespVO;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerDO;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
import cn.iocoder.yudao.module.crm.service.permission.bo.CrmPermissionTransferReqBO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
@ -30,9 +26,6 @@ public interface CrmCustomerConvert {
CrmCustomerConvert INSTANCE = Mappers.getMapper(CrmCustomerConvert.class);
// TODO @puhui999可以清理掉可以用 BeanUtil 替代的方法哈
CrmCustomerDO convert(CrmCustomerSaveReqVO bean);
CrmCustomerRespVO convert(CrmCustomerDO bean);
/**
@ -73,8 +66,4 @@ public interface CrmCustomerConvert {
return result;
}
CrmCustomerPoolConfigRespVO convert(CrmCustomerPoolConfigDO customerPoolConfig);
CrmCustomerPoolConfigDO convert(CrmCustomerPoolConfigSaveReqVO updateReqVO);
}

View File

@ -3,14 +3,12 @@ package cn.iocoder.yudao.module.crm.convert.customer;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
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.dal.dataobject.customer.CrmCustomerLimitConfigDO;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
/**
@ -23,13 +21,8 @@ public interface CrmCustomerLimitConfigConvert {
CrmCustomerLimitConfigConvert INSTANCE = Mappers.getMapper(CrmCustomerLimitConfigConvert.class);
// TODO @puhui999可以把 convert 改成 BeanUtils
CrmCustomerLimitConfigDO convert(CrmCustomerLimitConfigSaveReqVO bean);
CrmCustomerLimitConfigRespVO convert(CrmCustomerLimitConfigDO bean);
List<CrmCustomerLimitConfigRespVO> convertList(List<CrmCustomerLimitConfigDO> list);
PageResult<CrmCustomerLimitConfigRespVO> convertPage(PageResult<CrmCustomerLimitConfigDO> page);
default PageResult<CrmCustomerLimitConfigRespVO> convertPage(PageResult<CrmCustomerLimitConfigDO> pageResult,

View File

@ -105,7 +105,10 @@ public class CrmContactDO extends BaseDO {
* 最后跟进时间
*/
private LocalDateTime contactLastTime;
// TODO @puhui999增加一个字段 contactLastContent最后跟进内容
/**
* 最后跟进内容
*/
private String contactLastContent;
/**
* 下次联系时间
*/

View File

@ -118,7 +118,10 @@ public class CrmCustomerDO extends BaseDO {
* 最后跟进时间
*/
private LocalDateTime contactLastTime;
// TODO @puhui999增加一个字段 contactLastContent最后跟进内容
/**
* 最后跟进内容
*/
private String contactLastContent;
/**
* 下次联系时间
*/

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.crm.dal.mysql.customer;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.customer.CrmCustomerPoolConfigDO;
import org.apache.ibatis.annotations.Mapper;
@ -11,4 +12,9 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface CrmCustomerPoolConfigMapper extends BaseMapperX<CrmCustomerPoolConfigDO> {
default CrmCustomerPoolConfigDO selectOne() {
return selectOne(new LambdaQueryWrapperX<CrmCustomerPoolConfigDO>().last("LIMIT 1"));
}
}

View File

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

View File

@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
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.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_INDUSTRY;
/**
* 行业的 {@link IParseFunction} 实现类
@ -15,9 +16,7 @@ import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_I
*/
@Component
@Slf4j
public class CrmIndustryParseFunction implements IParseFunction {
public static final String NAME = "getIndustryById";
public class CrmCustomerIndustryParseFunction implements IParseFunction {
@Override
public boolean executeBefore() {
@ -26,7 +25,7 @@ public class CrmIndustryParseFunction implements IParseFunction {
@Override
public String functionName() {
return NAME;
return GET_CUSTOMER_INDUSTRY;
}
@Override

View File

@ -7,6 +7,7 @@ import lombok.extern.slf4j.Slf4j;
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.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_LEVEL;
/**
* 客户等级的 {@link IParseFunction} 实现类
@ -15,9 +16,7 @@ import static cn.iocoder.yudao.module.crm.enums.DictTypeConstants.CRM_CUSTOMER_L
*/
@Component
@Slf4j
public class CrmLevelParseFunction implements IParseFunction {
public static final String NAME = "getLevel";
public class CrmCustomerLevelParseFunction implements IParseFunction {
@Override
public boolean executeBefore() {
@ -26,7 +25,7 @@ public class CrmLevelParseFunction implements IParseFunction {
@Override
public String functionName() {
return NAME;
return GET_CUSTOMER_LEVEL;
}
@Override

View File

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

View File

@ -7,17 +7,18 @@ import lombok.extern.slf4j.Slf4j;
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.operatelog.CrmParseFunctionNameConstants.GET_CUSTOMER_SOURCE;
/**
* 客户来源的 {@link IParseFunction} 实现类
* CRM 客户来源的 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Component
@Slf4j
public class CrmSourceParseFunction implements IParseFunction {
public class CrmCustomerSourceParseFunction implements IParseFunction {
public static final String NAME = "getSource";
public static final String NAME = "getCustomerSource";
@Override
public boolean executeBefore() {
@ -26,7 +27,7 @@ public class CrmSourceParseFunction implements IParseFunction {
@Override
public String functionName() {
return NAME;
return GET_CUSTOMER_SOURCE;
}
@Override

View File

@ -1,44 +0,0 @@
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
*/
@Component
@Slf4j
public class CrmSysUserParseFunction implements IParseFunction {
public static final String NAME = "getUserById";
@Resource
private AdminUserApi adminUserApi;
@Override
public boolean executeBefore() {
return true; // 先转换值后对比
}
@Override
public String functionName() {
return NAME;
}
@Override
public String apply(Object value) {
if (StrUtil.isEmptyIfStr(value)) {
return "";
}
AdminUserRespDTO adminUserRespDTO = adminUserApi.getUser(Long.parseLong(value.toString()));
return adminUserRespDTO == null ? "" : adminUserRespDTO.getNickname();
}
}

View File

@ -5,7 +5,6 @@ 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.CrmCustomerLimitConfigSaveReqVO;
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.mysql.customer.CrmCustomerLimitConfigMapper;
import cn.iocoder.yudao.module.crm.enums.customer.CrmCustomerLimitConfigTypeEnum;
@ -49,7 +48,7 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig
public Long createCustomerLimitConfig(CrmCustomerLimitConfigSaveReqVO createReqVO) {
validateUserAndDept(createReqVO.getUserIds(), createReqVO.getDeptIds());
// 插入
CrmCustomerLimitConfigDO customerLimitConfig = CrmCustomerLimitConfigConvert.INSTANCE.convert(createReqVO);
CrmCustomerLimitConfigDO customerLimitConfig = BeanUtils.toBean(createReqVO, CrmCustomerLimitConfigDO.class);
customerLimitConfigMapper.insert(customerLimitConfig);
// 记录操作日志上下文
@ -66,7 +65,7 @@ public class CrmCustomerLimitConfigServiceImpl implements CrmCustomerLimitConfig
CrmCustomerLimitConfigDO oldLimitConfig = validateCustomerLimitConfigExists(updateReqVO.getId());
validateUserAndDept(updateReqVO.getUserIds(), updateReqVO.getDeptIds());
// 更新
CrmCustomerLimitConfigDO updateObj = CrmCustomerLimitConfigConvert.INSTANCE.convert(updateReqVO);
CrmCustomerLimitConfigDO updateObj = BeanUtils.toBean(updateReqVO, CrmCustomerLimitConfigDO.class);
customerLimitConfigMapper.updateById(updateObj);
// 记录操作日志上下文

View File

@ -1,8 +1,7 @@
package cn.iocoder.yudao.module.crm.service.customer;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.crm.controller.admin.customer.vo.poolconfig.CrmCustomerPoolConfigSaveReqVO;
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.mysql.customer.CrmCustomerPoolConfigMapper;
import com.mzt.logapi.context.LogRecordContext;
@ -34,8 +33,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
*/
@Override
public CrmCustomerPoolConfigDO getCustomerPoolConfig() {
// TODO @puhui999这个要搞到 mapper 里噢
return customerPoolConfigMapper.selectOne(new LambdaQueryWrapperX<CrmCustomerPoolConfigDO>().last("LIMIT 1"));
return customerPoolConfigMapper.selectOne();
}
/**
@ -49,7 +47,7 @@ public class CrmCustomerPoolConfigServiceImpl implements CrmCustomerPoolConfigSe
public void saveCustomerPoolConfig(CrmCustomerPoolConfigSaveReqVO saveReqVO) {
// 存在则进行更新
CrmCustomerPoolConfigDO dbConfig = getCustomerPoolConfig();
CrmCustomerPoolConfigDO poolConfig = CrmCustomerConvert.INSTANCE.convert(saveReqVO);
CrmCustomerPoolConfigDO poolConfig = BeanUtils.toBean(saveReqVO, CrmCustomerPoolConfigDO.class);
if (Objects.nonNull(dbConfig)) {
customerPoolConfigMapper.updateById(poolConfig.setId(dbConfig.getId()));
// 记录操作日志上下文

View File

@ -73,7 +73,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
validateCustomerExceedOwnerLimit(createReqVO.getOwnerUserId(), 1);
// 2. 插入客户
CrmCustomerDO customer = CrmCustomerConvert.INSTANCE.convert(createReqVO)
CrmCustomerDO customer = BeanUtils.toBean(createReqVO, CrmCustomerDO.class)
.setLockStatus(false).setDealStatus(false)
.setContactLastTime(LocalDateTime.now());
// TODO @puhui999可能要加个 receiveTime 字段记录最后接收时间
@ -100,7 +100,7 @@ public class CrmCustomerServiceImpl implements CrmCustomerService {
CrmCustomerDO oldCustomer = validateCustomerExists(updateReqVO.getId());
// 2. 更新客户
CrmCustomerDO updateObj = CrmCustomerConvert.INSTANCE.convert(updateReqVO);
CrmCustomerDO updateObj = BeanUtils.toBean(updateReqVO, CrmCustomerDO.class);
customerMapper.updateById(updateObj);
// 3. 记录操作日志上下文

View File

@ -7,13 +7,11 @@ import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCateg
import cn.iocoder.yudao.module.product.controller.admin.category.vo.ProductCategoryUpdateReqVO;
import cn.iocoder.yudao.module.product.dal.dataobject.category.ProductCategoryDO;
import cn.iocoder.yudao.module.product.dal.mysql.category.ProductCategoryMapper;
import jakarta.annotation.Resource;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.Import;
import jakarta.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals;
import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertServiceException;
@ -152,12 +150,12 @@ public class ProductCategoryServiceImplTest extends BaseDbUnitTest {
reqVO.setParentId(PARENT_ID_NULL);
// 调用
List<ProductCategoryDO> list = productCategoryService.getEnableCategoryList(reqVO);
List<ProductCategoryDO> all = productCategoryService.getEnableCategoryList(new ProductCategoryListReqVO());
// 断言
assertEquals(1, list.size());
assertEquals(4, all.size());
assertPojoEquals(dbCategory, list.get(0));
//List<ProductCategoryDO> list = productCategoryService.getEnableCategoryList(reqVO);
//List<ProductCategoryDO> all = productCategoryService.getEnableCategoryList(new ProductCategoryListReqVO());
//// 断言
//assertEquals(1, list.size());
//assertEquals(4, all.size());
//assertPojoEquals(dbCategory, list.get(0));
}
}

View File

@ -0,0 +1,17 @@
package cn.iocoder.yudao.module.system.enums.operatelog;
/**
* functionName 常量枚举
* 方便别的模块调用
*
* @author HUIHUI
*/
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,6 +8,8 @@ import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_ADMIN_USER_BY_ID;
/**
* 管理员名字的 {@link IParseFunction} 实现类
*
@ -22,7 +24,7 @@ public class AdminUserParseFunction implements IParseFunction {
@Override
public String functionName() {
return "getAdminUserById";
return GET_ADMIN_USER_BY_ID;
}
@Override

View File

@ -6,6 +6,8 @@ import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_AREA;
/**
* 地名的 {@link IParseFunction} 实现类
*
@ -22,7 +24,7 @@ public class AreaParseFunction implements IParseFunction {
@Override
public String functionName() {
return "getAreaById";
return GET_AREA;
}
@Override

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
package cn.iocoder.yudao.module.system.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
@ -7,16 +7,16 @@ import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_BOOLEAN;
/**
* 行业的 {@link IParseFunction} 实现类
* 是否类型 {@link IParseFunction} 实现类
*
* @author HUIHUI
*/
@Component
@Slf4j
public class CrmBooleanParseFunction implements IParseFunction {
public static final String NAME = "getBooleanById";
public class BooleanParseFunction implements IParseFunction {
@Override
public boolean executeBefore() {
@ -25,7 +25,7 @@ public class CrmBooleanParseFunction implements IParseFunction {
@Override
public String functionName() {
return NAME;
return GET_BOOLEAN;
}
@Override

View File

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

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.crm.framework.operatelog.core;
package cn.iocoder.yudao.module.system.framework.operatelog.core;
import cn.hutool.core.util.StrUtil;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
@ -7,6 +7,8 @@ import com.mzt.logapi.service.IParseFunction;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import static cn.iocoder.yudao.module.system.enums.operatelog.SysParseFunctionNameConstants.GET_SEX;
/**
* 行业的 {@link IParseFunction} 实现类
*
@ -14,9 +16,7 @@ import org.springframework.stereotype.Component;
*/
@Component
@Slf4j
public class CrmSexParseFunction implements IParseFunction {
public static final String NAME = "getSexById";
public class SexParseFunction implements IParseFunction {
@Override
public boolean executeBefore() {
@ -25,7 +25,7 @@ public class CrmSexParseFunction implements IParseFunction {
@Override
public String functionName() {
return NAME;
return GET_SEX;
}
@Override