Commit ba3c2b1f by zhouhaibao

feat(used-car): 添加门店评级字段支持

- 在 UsedCarTrafficTarget 实体类中新增 storeRating 字段及注解配置
- 在 UsedCarTrafficTargetDTO 数据传输对象中添加 storeRating 属性
- 更新 Excel 导入服务以支持门店评级数据映射
- 修改 MyBatis 映射文件以包含 storeRating 字段的数据库操作
- 完善门店评级字段的增删改查 SQL 配置
1 parent 2d1b1daf
...@@ -25,6 +25,9 @@ public class UsedCarTrafficTargetDTO implements Serializable { ...@@ -25,6 +25,9 @@ public class UsedCarTrafficTargetDTO implements Serializable {
@ApiModelProperty("品牌定位") @ApiModelProperty("品牌定位")
private String brandPositioning; private String brandPositioning;
@ApiModelProperty("门店评级")
private String storeRating;
@ApiModelProperty("新车订单目标(台/月)") @ApiModelProperty("新车订单目标(台/月)")
private Integer newCarOrderTarget; private Integer newCarOrderTarget;
......
...@@ -60,6 +60,13 @@ public class UsedCarTrafficTarget implements Serializable { ...@@ -60,6 +60,13 @@ public class UsedCarTrafficTarget implements Serializable {
private String brandPositioning; private String brandPositioning;
/** /**
* 门店评级
*/
@Column(name = "store_rating")
@ApiModelProperty(notes = "门店评级")
private String storeRating;
/**
* 新车订单目标(台/月) * 新车订单目标(台/月)
*/ */
@Column(name = "new_car_order_target") @Column(name = "new_car_order_target")
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
<result column="brand" property="brand" jdbcType="VARCHAR"/> <result column="brand" property="brand" jdbcType="VARCHAR"/>
<result column="car_model_remark" property="carModelRemark" jdbcType="VARCHAR"/> <result column="car_model_remark" property="carModelRemark" jdbcType="VARCHAR"/>
<result column="brand_positioning" property="brandPositioning" jdbcType="VARCHAR"/> <result column="brand_positioning" property="brandPositioning" jdbcType="VARCHAR"/>
<result column="store_rating" property="storeRating" jdbcType="VARCHAR"/>
<result column="new_car_order_target" property="newCarOrderTarget" jdbcType="INTEGER"/> <result column="new_car_order_target" property="newCarOrderTarget" jdbcType="INTEGER"/>
<result column="target_replace_rate" property="targetReplaceRate" jdbcType="DECIMAL"/> <result column="target_replace_rate" property="targetReplaceRate" jdbcType="DECIMAL"/>
<result column="recycle_target" property="recycleTarget" jdbcType="INTEGER"/> <result column="recycle_target" property="recycleTarget" jdbcType="INTEGER"/>
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, traffic_party_id, funding_tax_entity, brand, car_model_remark, brand_positioning, id, traffic_party_id, funding_tax_entity, brand, car_model_remark, brand_positioning,
store_rating,
new_car_order_target, target_replace_rate, recycle_target, brand_replace_rate, new_car_order_target, target_replace_rate, recycle_target, brand_replace_rate,
replace_order_eval_convert_rate, avg_profit_diff, premium_rate, replace_order_eval_rate, replace_order_eval_convert_rate, avg_profit_diff, premium_rate, replace_order_eval_rate,
created_by, created_date, updated_by, updated_date, deleted_flag created_by, created_date, updated_by, updated_date, deleted_flag
...@@ -49,6 +51,7 @@ ...@@ -49,6 +51,7 @@
<if test="brand != null">brand,</if> <if test="brand != null">brand,</if>
<if test="carModelRemark != null">car_model_remark,</if> <if test="carModelRemark != null">car_model_remark,</if>
<if test="brandPositioning != null">brand_positioning,</if> <if test="brandPositioning != null">brand_positioning,</if>
<if test="storeRating != null">store_rating,</if>
<if test="newCarOrderTarget != null">new_car_order_target,</if> <if test="newCarOrderTarget != null">new_car_order_target,</if>
<if test="targetReplaceRate != null">target_replace_rate,</if> <if test="targetReplaceRate != null">target_replace_rate,</if>
<if test="recycleTarget != null">recycle_target,</if> <if test="recycleTarget != null">recycle_target,</if>
...@@ -69,6 +72,7 @@ ...@@ -69,6 +72,7 @@
<if test="brand != null">#{brand, jdbcType=VARCHAR},</if> <if test="brand != null">#{brand, jdbcType=VARCHAR},</if>
<if test="carModelRemark != null">#{carModelRemark, jdbcType=VARCHAR},</if> <if test="carModelRemark != null">#{carModelRemark, jdbcType=VARCHAR},</if>
<if test="brandPositioning != null">#{brandPositioning, jdbcType=VARCHAR},</if> <if test="brandPositioning != null">#{brandPositioning, jdbcType=VARCHAR},</if>
<if test="storeRating != null">#{storeRating, jdbcType=VARCHAR},</if>
<if test="newCarOrderTarget != null">#{newCarOrderTarget, jdbcType=INTEGER},</if> <if test="newCarOrderTarget != null">#{newCarOrderTarget, jdbcType=INTEGER},</if>
<if test="targetReplaceRate != null">#{targetReplaceRate, jdbcType=DECIMAL},</if> <if test="targetReplaceRate != null">#{targetReplaceRate, jdbcType=DECIMAL},</if>
<if test="recycleTarget != null">#{recycleTarget, jdbcType=INTEGER},</if> <if test="recycleTarget != null">#{recycleTarget, jdbcType=INTEGER},</if>
...@@ -93,6 +97,7 @@ ...@@ -93,6 +97,7 @@
<if test="brand != null">brand = #{brand, jdbcType=VARCHAR},</if> <if test="brand != null">brand = #{brand, jdbcType=VARCHAR},</if>
<if test="carModelRemark != null">car_model_remark = #{carModelRemark, jdbcType=VARCHAR},</if> <if test="carModelRemark != null">car_model_remark = #{carModelRemark, jdbcType=VARCHAR},</if>
<if test="brandPositioning != null">brand_positioning = #{brandPositioning, jdbcType=VARCHAR},</if> <if test="brandPositioning != null">brand_positioning = #{brandPositioning, jdbcType=VARCHAR},</if>
<if test="storeRating != null">store_rating = #{storeRating, jdbcType=VARCHAR},</if>
<if test="newCarOrderTarget != null">new_car_order_target = #{newCarOrderTarget, jdbcType=INTEGER},</if> <if test="newCarOrderTarget != null">new_car_order_target = #{newCarOrderTarget, jdbcType=INTEGER},</if>
<if test="targetReplaceRate != null">target_replace_rate = #{targetReplaceRate, jdbcType=DECIMAL},</if> <if test="targetReplaceRate != null">target_replace_rate = #{targetReplaceRate, jdbcType=DECIMAL},</if>
<if test="recycleTarget != null">recycle_target = #{recycleTarget, jdbcType=INTEGER},</if> <if test="recycleTarget != null">recycle_target = #{recycleTarget, jdbcType=INTEGER},</if>
......
  • @wangxw1
    commented
    Master

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

    1. 数据校验与类型安全(最佳实践/健壮性)

    • 问题描述:在 UsedCarTrafficTargetDTO 中新增的 storeRating(门店评级)字段类型为 String,但未添加任何 JSR-303 数据校验注解(如 @NotBlank、@Size 或 @Pattern)。
    • 影响分析:如果“门店评级”有固定的取值范围(例如:A/B/C,或 1-5星),纯字符串且无校验会导致前端或外部调用方传入非法数据(如超长字符、特殊字符等),产生脏数据。
    • 优化建议:建议根据业务实际情况,在 DTO 中增加相应的校验注解;如果取值是固定的几个状态,建议使用枚举(Enum)来代替 String 以提升类型安全性。 java // 示例:如果为字符串,建议增加长度或正则限制 @ApiModelProperty("门店评级") @Size(max = 10, message = "门店评级长度不能超过10") private String storeRating;

    2. 数据库 DDL 脚本同步提醒(工程实践)

    • 问题描述:本次变更在实体类和 MyBatis XML 中新增了 store_rating 字段的映射。
    • 影响分析:代码层面已经准备好读写新字段,如果在部署代码前未在目标数据库中执行相应的 ALTER TABLE 语句,会导致系统上线后引发 SQL 异常(找不到列)。
    • 优化建议:请确认对应的数据库 DDL 脚本(如 Flyway/Liquibase 脚本或手动更新 SQL)已经包含在本次发布计划中。

    3. 提交信息与代码变更范围不一致(提交规范)

    • 问题描述:Commit message 中提到了“更新 Excel 导入服务以支持门店评级数据映射”,但在本次提交的代码 Diff 中并未看到任何关于 Excel 导入服务(如 Service 类或 Listener)的修改。
    • 影响分析:可能存在漏提交文件的情况,或者 Commit message 描述超出了当前实际 Commit 的范围,影响代码变更的可追溯性。
    • 优化建议:请核对是否遗漏了 Excel 导入相关的代码文件未提交。如果分批提交,建议 Commit message 与当前实际变更内容保持严格一致。

    二、评分明细

    • 1. 功能实现的正确性与健壮性(40/40分)

      • 理由:代码逻辑正确,XML 映射无误。严格遵守了“MyBatis 不允许使用子查询”的规则,且对 DTO 的修改属于向后兼容的扩展,未破坏 Dubbo 接口的已有请求参数。功能实现完全达标。
    • 2. 安全性与潜在风险(29/30分)

      • 理由:MyBatis 中新增字段均正确使用了 #{} 进行参数化预编译,无 SQL 注入风险。扣掉 1 分是因为 DTO 缺少输入校验,存在轻微的脏数据录入风险。
    • 3. 最佳实践与可维护性(18/20分)

      • 理由:命名规范,结构清晰,Swagger 注解完备。扣 2 分是因为对于“评级”这类具有潜在枚举属性的字段,使用纯 String 且无约束不是最优的领域建模实践。
    • 4. 性能与资源利用(5/5分)

      • 理由:仅为常规的字段扩展,MyBatis 的动态 SQL <if> 标签使用规范,不存在性能瓶颈或资源浪费。
    • 5. 提交信息质量(4/5分)

      • 理由:Commit 采用了标准的约定式提交(Conventional Commits)格式,内容清晰详尽。扣 1 分是因为描述内容与实际 Diff 的文件范围存在不一致(Excel 导入服务未见代码)。

    总分:96分

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