Commit 550bd119 by 崔彦峰

feat(pad): 新增PAD端车况管理功能

- 添加CarConditionAddRequest和CarConditionEditRequest请求类
- 更新车况单来源描述,将"生意助手小程序"改为"生意助手员工版小程序"
- 在新增车况逻辑中初始化status和aiReportStatus为0
- 根据车况单来源设置对应的销售或转化信息字段
- 在服务层设置操作人和商户信息到请求对象中
2 parents b79ba976 0b4adbe7
......@@ -231,10 +231,10 @@ public class CarCondition implements Serializable {
private Integer aiReportStatus;
/**
* 车况单来源 1-展业助手app 2-生意助手小程序 3-车生活助手小程序
* 车况单来源 1-展业助手app 2-生意助手员工版小程序 3-车生活助手小程序
*/
@TableField(value = "source")
@Schema(description = "车况单来源 1-展业助手app 2-生意助手小程序 3-车生活助手小程序")
@Schema(description = "车况单来源 1-展业助手app 2-生意助手员工版小程序 3-车生活助手小程序")
private Integer source;
/**
......
package com.gsc4cloud.gsc.vpc.api.req.pad.carcondition;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gsc4cloud.gsc.vpc.api.dto.pad.reqdto.evalorder.EvalOrderBasicReqDTO;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* PAD端车况新增请求
*/
@Data
@Schema(description = "PAD端车况新增请求")
public class CarConditionAddRequest implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "评估单编号")
private String evalOrderNo;
@NotBlank(message = "车主姓名不能为空")
@Schema(description = "车主姓名")
private String ownerName;
@Schema(description = "车牌号")
private String licensePlate;
@Schema(description = "车架号")
private String vin;
@Schema(description = "上牌时间(注册日期)")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date registrationDate;
@Schema(description = "品牌型号")
private String brandModel;
@Schema(description = "销售用户id(4S店)")
private String sellerUserId;
@Schema(description = "销售姓名(4S店)")
private String sellerName;
@Schema(description = "销售商户号(4S店)")
private Integer sellerMerchantId;
@Schema(description = "销售(4S店)商户名称")
private String sellerMerchantName;
@Schema(description = "转化用户id(园区店)")
private String conversionUserId;
@Schema(description = "转化姓名(园区店)")
private String conversionName;
@Schema(description = "转化商户号(园区店)")
private Integer conversionMerchantId;
@Schema(description = "转化(园区店)商户名称")
private String conversionMerchantName;
@Schema(description = "行驶证图片URL")
private String drivingLicenseImgUrl;
@Schema(description = "铭牌图片URL")
private String nameplateImgUrl;
@Schema(description = "左前45度图片URL")
private String leftFrontImgUrl;
@Schema(description = "右前45度图片URL")
private String rightFrontImgUrl;
@Schema(description = "仪表公里数图片URL")
private String mileageImgUrl;
@Schema(description = "中控台全景图片URL")
private String centerConsoleImgUrl;
@Schema(description = "主驾全景图片URL")
private String driverSeatImgUrl;
@Schema(description = "后排全景图片URL")
private String rearSeatImgUrl;
@Schema(description = "其他细节图片URL")
private String otherDetailImgUrl;
@Schema(description = "车况描述")
private String conditionDescription;
@Schema(description = "录入状态:0-草稿(信息待补全),1-已提交(已录入)")
private Integer entryStatus;
@NotNull(message = "车况单来源不能为空")
@Schema(description = "车况单来源 1-展业助手app 2-生意助手员工版小程序 3-车生活助手小程序")
private Integer source;
@Schema(description = "操作人姓名")
private String operator;
@Schema(description = "操作人id")
private String operatorId;
@Schema(description = "操作人所在门店id")
private Integer merchantId;
@Schema(description = "操作人所在门店名称")
private String merchantName;
}
package com.gsc4cloud.gsc.vpc.api.req.pad.carcondition;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import jakarta.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* PAD端车况编辑请求
*/
@Data
@Schema(description = "PAD端车况编辑请求")
public class CarConditionEditRequest implements Serializable {
private static final long serialVersionUID = 1L;
@NotNull(message = "主键ID不能为空")
@Schema(description = "主键id")
private Integer id;
@Schema(description = "车主姓名")
private String ownerName;
@Schema(description = "车牌号")
private String licensePlate;
@Schema(description = "车架号")
private String vin;
@Schema(description = "上牌时间(注册日期)")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date registrationDate;
@Schema(description = "品牌型号")
private String brandModel;
@Schema(description = "销售用户id(4S店)")
private String sellerUserId;
@Schema(description = "销售姓名(4S店)")
private String sellerName;
@Schema(description = "销售商户号(4S店)")
private Integer sellerMerchantId;
@Schema(description = "销售(4S店)商户名称")
private String sellerMerchantName;
@Schema(description = "转化用户id(园区店)")
private String conversionUserId;
@Schema(description = "转化姓名(园区店)")
private String conversionName;
@Schema(description = "转化商户号(园区店)")
private Integer conversionMerchantId;
@Schema(description = "转化(园区店)商户名称")
private String conversionMerchantName;
@Schema(description = "行驶证图片URL")
private String drivingLicenseImgUrl;
@Schema(description = "铭牌图片URL")
private String nameplateImgUrl;
@Schema(description = "左前45度图片URL")
private String leftFrontImgUrl;
@Schema(description = "右前45度图片URL")
private String rightFrontImgUrl;
@Schema(description = "仪表公里数图片URL")
private String mileageImgUrl;
@Schema(description = "中控台全景图片URL")
private String centerConsoleImgUrl;
@Schema(description = "主驾全景图片URL")
private String driverSeatImgUrl;
@Schema(description = "后排全景图片URL")
private String rearSeatImgUrl;
@Schema(description = "其他细节图片URL")
private String otherDetailImgUrl;
@Schema(description = "车况描述")
private String conditionDescription;
@Schema(description = "录入状态:0-草稿(信息待补全),1-已提交(已录入)")
private Integer entryStatus;
@Schema(description = "操作人姓名")
private String operator;
@Schema(description = "操作人id")
private String operatorId;
@Schema(description = "操作人所在门店id")
private Integer merchantId;
@Schema(description = "操作人所在门店名称")
private String merchantName;
}
  • @wangxw1
    commented
    Master

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

    1. 安全性与设计规范:请求参数中包含敏感上下文信息(高风险)

    • 问题描述:在 CarConditionAddRequest 和 CarConditionEditRequest 中,定义了 operator, operatorId, merchantId, merchantName 等字段。虽然提交信息提到“在服务层设置操作人和商户信息到请求对象中”,但这是一种不良设计。将这些字段放在前端请求的 DTO 并暴露在 Swagger 中,不仅会误导前端开发者,如果服务层存在遗漏覆盖的情况,还极易引发越权漏洞(IDOR)或数据伪造。
    • 优化建议:
      • 从 Request DTO 中移除当前操作人、门店相关的字段。
      • 遵循“零信任”原则,这些上下文信息应当在 Controller 或 Service 层直接从网关透传的 Header、Token 或 Spring Security Context 中获取。
      • 如果需要在服务层传递这些信息,建议将 Request DTO 转换为内部的 BO(Business Object)或 Entity 后再进行赋值,而不是复用并污染 Request DTO。

    2. 功能健壮性:枚举值与核心业务字段缺乏校验(中风险)

    • 问题描述:请求类中的核心状态字段缺乏范围约束。例如,source 字段虽然加了 @NotNull,但未限制其只能是 1, 2, 3;entryStatus(0-草稿,1-已提交)不仅没有非空校验,也没有范围校验。此外,车架号(vin)、车牌号(licensePlate)作为核心车辆标识,缺乏基础的格式或长度校验。
    • 优化建议:
      • 对于 source 和 entryStatus,建议使用 @Min 和 @Max 注解限制数值范围,或者自定义校验注解结合枚举类使用。
      • 对于 vin(通常为17位字母数字)和 licensePlate,建议添加 @Pattern 正则校验或 @Size 长度校验,防止脏数据入库。

    3. 可维护性与规范:无用的类导入及代码重复(低风险)

    • 问题描述:
      • 违反《阿里巴巴 Java 开发手册》规范:CarConditionAddRequest.java 第 4 行存在无用的导入 import com.gsc4cloud.gsc.vpc.api.dto.pad.reqdto.evalorder.EvalOrderBasicReqDTO;。
      • CarConditionAddRequest 与 CarConditionEditRequest 存在大量重复字段,违反 DRY(Don't Repeat Yourself)原则。
    • 优化建议:
      • 清理未使用的 import 语句,保持代码整洁。
      • 建议抽取一个公共的基类(如 CarConditionBaseRequest),包含所有共用字段。Add 和 Edit 请求类继承该基类,Edit 请求类额外添加 @NotNull(message = "主键ID不能为空") private Integer id; 即可,大幅提升代码复用率。

    二、评分明细

    • 功能实现的正确性与健壮性(35/40分):基础增改接口定义正确,Swagger注解完善。扣分项在于核心状态字段和业务标识字段缺乏严格的边界及格式校验。
    • 安全性与潜在风险(20/30分):扣分项在于将操作人、商户等敏感上下文信息暴露在前端请求 DTO 中,存在潜在的伪造风险和接口契约污染。
    • 最佳实践与可维护性(15/20分):使用了 Lombok 和 Validation 框架,表现良好。扣分项在于存在未使用的无用导入,以及新增与编辑的 DTO 存在大量重复代码,未进行抽象提取。
    • 性能与资源利用(5/5分):未见明显的性能问题,Feign 接口定义规范。
    • 提交信息质量(5/5分):Commit Message 格式规范,清晰描述了变更内容、原因以及具体的业务逻辑。

    总分:80分

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