Commit aeac756e by 崔彦峰

feat(clues): 新增线索管理功能实现

- 创建了新增线索请求类 AddCluesReq,包含车主信息、车辆信息、销售转化信息等字段
- 创建了新增线索响应类 AddCluesResp,用于返回生成的线索编号
- 在 CluesInfo 实体类中添加了 nextFollowTime 字段用于存储下次跟进时间
- 创建了线索管理远程调用接口 CluesRemote,提供 PAD 端新增线索功能
- 新增客户意向等级枚举 CustomerIntentLevelEnum,定义 A/B/C/D/O/H 等级别及跟进天数
- 实现了线索控制器 CluesController,提供 /clues/add 接口处理新增请求
- 更新了 CluesInfoMapper.xml 映射文件,添加 next_follow_time 字段映射和查询列表
- 创建了线索服务 CluesInfoService,实现线索新增业务逻辑和跟进时间计算
- 扩展了 EvalNoGenerator 工具类,增加线索编号生成功能
- 实现了 PAD 端线索控制器,集成远程调用和用户会话信息获取
- 修改员工管理接口,将返回类型从 List 改为分页 Page 对象
1 parent 0103a971
package com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.io.Serializable;
/**
* 新增线索响应类
*/
@Data
@Schema(description = "新增线索返回结果")
public class AddCluesResp implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "生成的线索编号")
private String cluesNo;
}
...@@ -62,6 +62,14 @@ public class CluesInfo implements Serializable { ...@@ -62,6 +62,14 @@ public class CluesInfo implements Serializable {
private Date enterTime; private Date enterTime;
/** /**
* 线索下一次跟进时间
*/
@TableField(value = "next_follow_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "线索下一次跟进时间")
private Date nextFollowTime;
/**
* 客户意向等级:A、B、C、D、O、H * 客户意向等级:A、B、C、D、O、H
*/ */
@TableField(value = "customer_intent_level") @TableField(value = "customer_intent_level")
......
package com.gsc4cloud.gsc.vpc.api.enums.clues;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 客户意向等级枚举
*/
@Getter
@AllArgsConstructor
public enum CustomerIntentLevelEnum {
O("O", "新车已定,旧车已签合同(客情回复,确认交车时间,1日内跟进)", 1),
H("H", "新车已定,旧车已评估报价,客户正在对比价格(1日内跟进)", 1),
A("A", "客户新车基本看好,一周内会购车,旧车已评估报价(2日内跟进)", 2),
B("B", "新车车型基本看好,预计一个月内会购车,旧车还未确定是否置换(5天内跟进)", 5),
C("C", "客户新车还未确定车型,旧车未确定置换(10天内跟进)", 10),
D("D", "新车未看具体车型,短期内不打算换车,旧车大概看看(20天跟进)", 20);
private final String code;
private final String desc;
private final int followDays;
public static CustomerIntentLevelEnum getByCode(String code) {
for (CustomerIntentLevelEnum level : values()) {
if (level.getCode().equals(code)) {
return level;
}
}
return null;
}
}
package com.gsc4cloud.gsc.vpc.api.feign.pad.clues;
import com.gsc4cloud.gsc.common.core.constant.ServiceNameConstants;
import com.gsc4cloud.gsc.common.core.util.R;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.AddCluesReq;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.AddCluesResp;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestHeader;
/**
* 线索管理远程调用接口
*/
@FeignClient(contextId = "cluesRemote", value = ServiceNameConstants.GSC_VCP_BIZ)
public interface CluesRemote {
/**
* PAD端新增线索
*/
@PostMapping("/clues/add")
R<AddCluesResp> addClues(@RequestBody AddCluesReq req, @RequestHeader("operatorName") String operatorName);
}
package com.gsc4cloud.gsc.vpc.api.req.pad.clues;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.io.Serializable;
/**
* 新增线索请求类
*/
@Data
@Schema(description = "新增线索请求参数")
public class AddCluesReq implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank(message = "车主名称不能为空")
@Schema(description = "车主名称")
private String carOwnerName;
@NotBlank(message = "车主电话不能为空")
@Schema(description = "车主电话,11位手机号")
private String carOwnerPhone;
@NotBlank(message = "客户意向等级不能为空")
@Schema(description = "客户意向等级:A、B、C、D、O、H")
private String customerIntentLevel;
@Schema(description = "车辆品牌名称")
private String carBrand;
@Schema(description = "子品牌id")
private Integer carChildsBrandId;
@Schema(description = "子品牌名字")
private String carChildsBrandName;
@Schema(description = "车系id")
private Integer carSeriesId;
@Schema(description = "车系名字")
private String carSeriesName;
@Schema(description = "车型id")
private Integer carTypeId;
@Schema(description = "车型名称")
private String carTypeName;
@NotBlank(message = "销售用户id不能为空")
@Schema(description = "销售用户id(4S店)")
private String sellerUserId;
@NotBlank(message = "销售姓名不能为空")
@Schema(description = "销售姓名(4S店)")
private String sellerName;
@NotNull(message = "销售商户号不能为空")
@Schema(description = "销售商户号(4S店)")
private Integer sellerMerchantId;
@NotBlank(message = "销售商户名称不能为空")
@Schema(description = "销售(4S店)商户名称")
private String sellerMerchantName;
@NotBlank(message = "转化用户id不能为空")
@Schema(description = "转化用户id(园区店)")
private String conversionUserId;
@NotBlank(message = "转化姓名不能为空")
@Schema(description = "转化姓名(园区店)")
private String conversionName;
@NotNull(message = "转化商户号不能为空")
@Schema(description = "转化商户号(园区店)")
private Integer conversionMerchantId;
@NotBlank(message = "转化商户名称不能为空")
@Schema(description = "转化(园区店)商户名称")
private String conversionMerchantName;
@Schema(description = "备注说明")
private String remark;
}
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(仅限 Top 3)

    1. 数据校验不完善,存在脏数据与越界风险(功能正确性与健壮性)

    • 位置:AddCluesReq.java
    • 问题描述:请求参数的校验过于基础。carOwnerPhone 仅使用了 @NotBlank,缺少对手机号格式的校验;customerIntentLevel 仅校验了非空,但业务上明确只有 "A, B, C, D, O, H" 几种状态,若前端传入非法字符串(如 "Z"),将在后续业务中引发异常或产生脏数据。
    • 优化建议:
      • 为手机号增加正则校验:@Pattern(regexp = "^1[3-9]\\d{9}$", message = "手机号格式不正确")
      • 为意向等级增加正则校验:@Pattern(regexp = "^[ABCDOH]$", message = "客户意向等级不合法")

    2. 违反阿里巴巴Java开发手册关于时间类型的规约(最佳实践与可维护性)

    • 位置:CluesInfo.java
    • 问题描述:新增的 nextFollowTime 字段使用了 java.util.Date 类型。根据《阿里巴巴 Java 开发手册》规约,强制要求在 JDK 8 及以上版本中使用 java.time.Instant、java.time.LocalDateTime 等新时间 API,因为 Date 存在线程不安全、设计缺陷(如月份从0开始)以及格式化性能等问题。
    • 优化建议:将 Date 替换为 LocalDateTime,并相应调整 @JsonFormat 注解(通常 Spring Boot 默认已支持 LocalDateTime 的序列化配置,按需保留 @JsonFormat)。

    3. 通过 Header 直接传递操作人信息存在伪造风险(安全性与潜在风险)

    • 位置:CluesRemote.java
    • 问题描述:Feign 接口中通过 @RequestHeader("operatorName") String operatorName 来接收操作人姓名。如果该服务直接暴露给前端,或者网关层没有对外部请求中的 operatorName 请求头进行严格的清洗与重写,攻击者可以通过抓包篡改 Header,伪造他人身份进行线索录入(越权/身份伪造风险)。
    • 优化建议:不建议明文传递用户信息。应通过网关统一解析 Token(如 JWT),将用户 ID/信息放入微服务请求头,或在服务内部通过 UserContextHolder(基于 ThreadLocal)直接获取当前登录用户信息。

    二、评分明细

    • 功能实现的正确性与健壮性(35/40分):基础功能实现完整,DTO 与枚举设计合理。扣分点在于请求参数缺少严格的正则与范围校验,可能导致脏数据入库。
    • 安全性与潜在风险(25/30分):未见明显的 SQL 注入风险(使用了 MyBatis Plus 的 @TableField 等标准用法)。扣分点在于通过 Header 明文传递操作人姓名存在被伪造的安全隐患。
    • 最佳实践与可维护性(17/20分):代码结构清晰,Swagger 注解完备,枚举类设计包含了业务逻辑(跟进天数),符合面向对象思想。扣分点在于使用了过时的 java.util.Date,不符合阿里规约。
    • 性能与资源利用(5/5分):无明显性能瓶颈。枚举类的 getByCode 虽使用遍历,但由于枚举项极少(6项),对性能无实质影响。
    • 提交信息质量(5/5分):Commit Message 符合 Angular 规范(feat(clues): ...),详细列出了变更点及业务含义,质量极高。

    总分:87分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!