Commit 96116aa6 by 崔彦峰

feat(clues): 添加二手车线索相关实体类

- 创建 CluesFollowRecord 实体类,用于存储线索跟进记录信息
- 创建 CluesInfo 实体类,用于存储二手车线索基本信息
- 创建 CluesOperationLog 实体类,用于记录线索操作日志
- 配置数据库表映射关系和字段注解
- 添加数据验证和文档注释支持
1 parent 252b6a0f
package com.gsc4cloud.gsc.vpc.api.entity.clues;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 二手车线索跟进记录表
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@TableName("vcp_clues_follow_record")
public class CluesFollowRecord implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
@Schema(description = "主键ID")
private Integer id;
/**
* 线索主键id
*/
@TableField(value = "clues_id")
@Schema(description = "线索主键id")
private Integer cluesId;
/**
* 跟进记录类型:1-普通跟进记录 2-24h内跟进记录
*/
@TableField(value = "follow_record_type")
@Schema(description = "跟进记录类型:1-普通跟进记录 2-24h内跟进记录")
private Integer followRecordType;
/**
* 跟进人id
*/
@TableField(value = "follow_user_id")
@Schema(description = "跟进人id")
private String followUserId;
/**
* 跟进人名称
*/
@TableField(value = "follow_user_name")
@Schema(description = "跟进人名称")
private String followUserName;
/**
* 跟进方式:1-电话 2-微信 3-到店 4-上门 5-短信 6-其他
*/
@TableField(value = "follow_style")
@Schema(description = "跟进方式:1-电话 2-微信 3-到店 4-上门 5-短信 6-其他")
private Integer followStyle;
/**
* 跟进结果:1-邀约验车 2-客户考虑中 3-不卖旧车 4-还在考虑收购价 5-还没定新车 6-成功收车 7-其他
*/
@TableField(value = "follow_result")
@Schema(description = "跟进结果:1-邀约验车 2-客户考虑中 3-不卖旧车 4-还在考虑收购价 5-还没定新车 6-成功收车 7-其他")
private Integer followResult;
/**
* 置换类型(当follow_result=1才有值):1-收车置换 2-不收车置换 3-未确定
*/
@TableField(value = "displacement_type")
@Schema(description = "置换类型(当follow_result=1才有值):1-收车置换 2-不收车置换 3-未确定")
private Integer displacementType;
/**
* 检测方式(当follow_result=1才有值):1-到店 2-远程 3-第三方 4-上门
*/
@TableField(value = "detection_mode")
@Schema(description = "检测方式(当follow_result=1才有值):1-到店 2-远程 3-第三方 4-上门")
private Integer detectionMode;
/**
* 暂败原因(当follow_result=3才有值):1-客户自行处理 2-家人不同意 3-第客户决定增购 4-旧车已处置 5-其他
*/
@TableField(value = "fail_reason")
@Schema(description = "暂败原因(当follow_result=3才有值):1-客户自行处理 2-家人不同意 3-第客户决定增购 4-旧车已处置 5-其他")
private Integer failReason;
/**
* 客户意向等级变更
*/
@TableField(value = "customer_intent_level_change")
@Schema(description = "客户意向等级变更")
private String customerIntentLevelChange;
/**
* 下一次跟进时间
*/
@TableField(value = "next_follow_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "下一次跟进时间")
private Date nextFollowTime;
/**
* 跟进内容
*/
@TableField(value = "follow_remark")
@Schema(description = "跟进内容")
private String followRemark;
/**
* 创建人
*/
@TableField(value = "created_by")
@Schema(description = "创建人")
private String createdBy;
/**
* 创建时间
*/
@TableField(value = "created_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "创建时间")
private Date createdDate;
/**
* 修改人
*/
@TableField(value = "updated_by")
@Schema(description = "修改人")
private String updatedBy;
/**
* 修改时间
*/
@TableField(value = "updated_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "修改时间")
private Date updatedDate;
/**
* 删除标识:N未删除,D已删除
*/
@TableField(value = "deleted_flag")
@TableLogic(value = "N", delval = "D")
@Schema(description = "删除标识:N未删除,D已删除")
private String deletedFlag;
}
package com.gsc4cloud.gsc.vpc.api.entity.clues;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 二手车线索信息表
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@TableName("vcp_clues_info")
public class CluesInfo implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
@Schema(description = "主键ID")
private Integer id;
/**
* 线索编号
*/
@TableField(value = "clues_no")
@Schema(description = "线索编号")
private String cluesNo;
/**
* 车主名称
*/
@TableField(value = "car_owner_name")
@Schema(description = "车主名称")
private String carOwnerName;
/**
* 车主电话,11位手机号
*/
@TableField(value = "car_owner_phone")
@Schema(description = "车主电话,11位手机号")
private String carOwnerPhone;
/**
* 线索录入时间
*/
@TableField(value = "enter_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "线索录入时间")
private Date enterTime;
/**
* 客户意向等级:A、B、C、D、O、H
*/
@TableField(value = "customer_intent_level")
@Schema(description = "客户意向等级:A、B、C、D、O、H")
private String customerIntentLevel;
/**
* 车辆品牌名称
*/
@TableField(value = "car_brand")
@Schema(description = "车辆品牌名称")
private String carBrand;
/**
* 子品牌id
*/
@TableField(value = "car_childs_brand_id")
@Schema(description = "子品牌id")
private Integer carChildsBrandId;
/**
* 子品牌名字
*/
@TableField(value = "car_childs_brand_name")
@Schema(description = "子品牌名字")
private String carChildsBrandName;
/**
* 车系id
*/
@TableField(value = "car_series_id")
@Schema(description = "车系id")
private Integer carSeriesId;
/**
* 车系名字
*/
@TableField(value = "car_series_name")
@Schema(description = "车系名字")
private String carSeriesName;
/**
* 车型id
*/
@TableField(value = "car_type_id")
@Schema(description = "车型id")
private Integer carTypeId;
/**
* 车型名称
*/
@TableField(value = "car_type_name")
@Schema(description = "车型名称")
private String carTypeName;
/**
* 销售用户id(4S店)
*/
@TableField(value = "seller_user_id")
@Schema(description = "销售用户id(4S店)")
private String sellerUserId;
/**
* 销售姓名(4S店)
*/
@TableField(value = "seller_name")
@Schema(description = "销售姓名(4S店)")
private String sellerName;
/**
* 销售商户号(4S店)
*/
@TableField(value = "seller_merchant_id")
@Schema(description = "销售商户号(4S店)")
private Integer sellerMerchantId;
/**
* 销售(4S店)商户名称
*/
@TableField(value = "seller_merchant_name")
@Schema(description = "销售(4S店)商户名称")
private String sellerMerchantName;
/**
* 转化用户id(园区店)
*/
@TableField(value = "conversion_user_id")
@Schema(description = "转化用户id(园区店)")
private String conversionUserId;
/**
* 转化姓名(园区店)
*/
@TableField(value = "conversion_name")
@Schema(description = "转化姓名(园区店)")
private String conversionName;
/**
* 转化商户号(园区店)
*/
@TableField(value = "conversion_merchant_id")
@Schema(description = "转化商户号(园区店)")
private Integer conversionMerchantId;
/**
* 转化(园区店)商户名称
*/
@TableField(value = "conversion_merchant_name")
@Schema(description = "转化(园区店)商户名称")
private String conversionMerchantName;
/**
* 备注说明
*/
@TableField(value = "remark")
@Schema(description = "备注说明")
private String remark;
/**
* 创建人
*/
@TableField(value = "created_by")
@Schema(description = "创建人")
private String createdBy;
/**
* 创建时间
*/
@TableField(value = "created_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "创建时间")
private Date createdDate;
/**
* 修改人
*/
@TableField(value = "updated_by")
@Schema(description = "修改人")
private String updatedBy;
/**
* 修改时间
*/
@TableField(value = "updated_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "修改时间")
private Date updatedDate;
/**
* 删除标识:N未删除,D已删除
*/
@TableField(value = "deleted_flag")
@TableLogic(value = "N", delval = "D")
@Schema(description = "删除标识:N未删除,D已删除")
private String deletedFlag;
}
package com.gsc4cloud.gsc.vpc.api.entity.clues;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 二手车线索操作日志表
*/
@AllArgsConstructor
@NoArgsConstructor
@Data
@TableName("vcp_clues_operation_log")
public class CluesOperationLog implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
@TableId(value = "id", type = IdType.AUTO)
@Schema(description = "主键ID")
private Integer id;
/**
* 线索主键id
*/
@TableField(value = "clues_id")
@Schema(description = "线索主键id")
private Integer cluesId;
/**
* 操作类型:1-创建线索 2-新增跟进 3-未状态变更 4-意向等级变更
*/
@TableField(value = "op_type")
@Schema(description = "操作类型:1-创建线索 2-新增跟进 3-未状态变更 4-意向等级变更")
private Integer opType;
/**
* 操作人id
*/
@TableField(value = "op_user_id")
@Schema(description = "操作人id")
private String opUserId;
/**
* 操作人名称
*/
@TableField(value = "op_user_name")
@Schema(description = "操作人名称")
private String opUserName;
/**
* 操作时间
*/
@TableField(value = "op_time")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "操作时间")
private Date opTime;
/**
* 操作内容
*/
@TableField(value = "op_content")
@Schema(description = "操作内容")
private String opContent;
/**
* 创建人
*/
@TableField(value = "created_by")
@Schema(description = "创建人")
private String createdBy;
/**
* 创建时间
*/
@TableField(value = "created_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "创建时间")
private Date createdDate;
/**
* 修改人
*/
@TableField(value = "updated_by")
@Schema(description = "修改人")
private String updatedBy;
/**
* 修改时间
*/
@TableField(value = "updated_date")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@Schema(description = "修改时间")
private Date updatedDate;
/**
* 删除标识:N未删除,D已删除
*/
@TableField(value = "deleted_flag")
@TableLogic(value = "N", delval = "D")
@Schema(description = "删除标识:N未删除,D已删除")
private String deletedFlag;
}
  • @wangxw1
    commented
    Master

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

    1. 【规范与可维护性】弃用 java.util.Date,强烈建议改用 java.time.LocalDateTime

    • 问题描述:实体类中所有时间字段(如 enterTime, createdDate, nextFollowTime 等)均使用了 java.util.Date。根据《阿里巴巴 Java 开发手册》规范,由于 java.util.Date 存在线程不安全、设计缺陷以及格式化存在并发问题,自 Java 8 起应全面使用 java.time.LocalDateTime(或 LocalDate/LocalTime)。
    • 优化建议: 将所有 Date 类型替换为 LocalDateTime,并同步修改 JSON 格式化注解: java @TableField(value = "created_date") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private LocalDateTime createdDate;

    2. 【健壮性与扩展性】主键及关联 ID 类型存在溢出风险,建议改为 Long

    • 问题描述:CluesOperationLog(操作日志表)和 CluesFollowRecord(跟进记录表)的主键 id 以及关联的 cluesId 使用了 Integer 类型。在业务量较大的二手车系统中,日志表和跟进记录表的数据量很容易突破 Integer 的最大值(约 21.4 亿),导致主键溢出插入失败。
    • 优化建议: 将实体类中的自增主键 id 及外键(如 cluesId)类型从 Integer 修改为 Long(对应数据库中的 BIGINT 类型)。 java @TableId(value = "id", type = IdType.AUTO) @Schema(description = "主键ID") private Long id;

    3. 【最佳实践】缺失 MyBatis-Plus 自动填充功能与枚举映射

    • 问题描述:
      • 审计字段未自动化:createdBy, createdDate, updatedBy, updatedDate 等通用审计字段需要开发人员每次手动赋值,容易遗漏,增加了代码冗余。
      • 魔数问题:如 followResult、opType 等字段,注释中定义了明确的状态码(如 1-邀约验车),但代码中直接使用 Integer,缺乏类型安全,极易产生脏数据。
    • 优化建议:

      • 利用 MyBatis-Plus 的自动填充功能管理审计字段:

        @TableField(value = "created_date", fill = FieldFill.INSERT)
        private LocalDateTime createdDate;
        
        @TableField(value = "updated_date", fill = FieldFill.INSERT_UPDATE)
        private LocalDateTime updatedDate;
        
      • 对于状态类字段,建议定义 Java Enum,并结合 MyBatis-Plus 的 @EnumValue 注解进行映射,以消除代码中的魔数并保证数据合法性。


    二、评分明细

    评审维度 满分 得分 扣分说明
    1. 功能正确性与健壮性 40 35 日志和记录表的主键使用 Integer 存在潜在的溢出风险(-5分)。
    2. 安全性与潜在风险 30 28 状态字段直接使用 Integer 接收,未做枚举限定,存在非法数值注入导致业务逻辑异常的微小风险(-2分)。
    3. 最佳实践与可维护性 20 12 严重违反阿里规范使用 java.util.Date(-5分);未使用框架提供的公共字段自动填充功能(-3分)。
    4. 性能与资源利用 5 5 纯实体类定义,无复杂逻辑,性能无影响。
    5. 提交信息质量 5 5 提交信息采用了 feat(clues): ... 标准规范,清晰列出了修改内容,非常优秀。

    总分:85分

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