Commit 5790af0a by 崔彦峰

feat(clues): 添加线索跟进记录详情字段和格式化功能

- 在 CluesFollowRecordListResp 中添加 createdDate 字段用于显示跟进时间
- 在 FollowRecordItemResp 中添加置换类型、检测方式、暂败原因和客户意向等级变更字段
- 根据跟进结果条件性显示置换类型和检测方式信息
- 根据跟进结果条件性显示暂败原因信息
- 添加客户意向等级变更信息展示
- 实现置换类型、检测方式和暂败原因的枚举描述转换方法
- 移除原有的跟进时间和跟进人信息显示逻辑
1 parent 3190abd5
......@@ -538,12 +538,17 @@ public class CluesInfoService extends ServiceImpl<CluesInfoMapper, CluesInfo> {
private String formatFollowRecord(FollowRecordItemResp followRecord) {
StringJoiner joiner = new StringJoiner(";");
joiner.add("跟进人:" + defaultText(followRecord.getFollowUserName()));
joiner.add("跟进方式:" + getFollowStyleDesc(followRecord.getFollowStyle()));
joiner.add("跟进结果:" + getFollowResultDesc(followRecord.getFollowResult()));
if (Objects.equals(followRecord.getFollowResult(), FollowResultEnum.INVITE_INSPECTION.getCode())) {
joiner.add("置换类型:" + getDisplacementTypeDesc(followRecord.getDisplacementType()));
joiner.add("检测方式:" + getDetectionModeDesc(followRecord.getDetectionMode()));
}
if (Objects.equals(followRecord.getFollowResult(), FollowResultEnum.NO_SELL_OLD_CAR.getCode())) {
joiner.add("战败原因:" + getFailReasonDesc(followRecord.getFailReason()));
}
joiner.add("客户意向等级:" + defaultText(followRecord.getCustomerIntentLevelChange()));
joiner.add("跟进内容:" + defaultText(followRecord.getFollowRemark()));
joiner.add("跟进时间:" + (followRecord.getCreatedDate() == null
? "" : DateUtil.formatDateTime(followRecord.getCreatedDate())));
return joiner.toString();
}
......@@ -557,6 +562,21 @@ public class CluesInfoService extends ServiceImpl<CluesInfoMapper, CluesInfo> {
return followResult == null ? defaultText(code) : followResult.getDesc();
}
private String getDisplacementTypeDesc(Integer code) {
DisplacementTypeEnum displacementType = DisplacementTypeEnum.getByCode(code);
return displacementType == null ? defaultText(code) : displacementType.getDesc();
}
private String getDetectionModeDesc(Integer code) {
DetectionModeEnum detectionMode = DetectionModeEnum.getByCode(code);
return detectionMode == null ? defaultText(code) : detectionMode.getDesc();
}
private String getFailReasonDesc(Integer code) {
FailReasonEnum failReason = FailReasonEnum.getByCode(code);
return failReason == null ? defaultText(code) : failReason.getDesc();
}
private String defaultText(Object value) {
return value == null ? "" : String.valueOf(value);
}
......
  • @wangxw1
    commented
    Master

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

    1. 健壮性与用户体验:枚举未匹配时的降级处理不当

    • 问题描述:在 getDisplacementTypeDesc、getDetectionModeDesc 等方法中,当传入的 code 无法匹配到对应的枚举时,代码使用了 defaultText(code) 进行降级。这会导致向前端或用户端直接输出数据库中的原始数字字典值(例如:“置换类型:99”)。
    • 影响分析:将系统内部的数字 code 直接暴露给用户,不仅会导致展示内容缺乏可读性,降低用户体验,还可能暴露内部数据结构。
    • 优化建议:当枚举未匹配时,建议返回空字符串 "" 或明确的占位提示(如 "未知")。 java private String getDisplacementTypeDesc(Integer code) { DisplacementTypeEnum displacementType = DisplacementTypeEnum.getByCode(code); // 建议替换为返回 "" 或 "未知" return displacementType == null ? "" : displacementType.getDesc(); }

    2. 潜在的功能逻辑遗漏:客户意向等级未进行枚举转换

    • 问题描述:在 formatFollowRecord 方法中,followRecord.getCustomerIntentLevelChange() 直接使用了 defaultText() 进行包装。
    • 影响分析:如果 CustomerIntentLevelChange 在 DTO 中是一个描述性字符串,则当前逻辑正常;但如果它和“置换类型”、“跟进结果”一样,也是一个 Integer 类型的枚举 Code,那么这里将直接输出数字(如“客户意向等级:2”),导致功能展示不符合预期。
    • 优化建议:请核对 followRecord.getCustomerIntentLevelChange() 的返回值类型。若为枚举 Code,请补充类似 getCustomerIntentLevelDesc(code) 的转换方法;若已是 String 描述,则可忽略此条。

    3. 可维护性:重复的枚举转换模板代码

    • 问题描述:新增的三个枚举描述获取方法(getDisplacementTypeDesc 等)逻辑高度一致,存在样板代码(Boilerplate Code)。
    • 影响分析:虽然当前代码量不大,但随着后续业务扩展,每增加一个枚举字段都需要新增一个私有方法,导致 Service 类变得臃肿,降低代码可维护性。
    • 优化建议:如果项目中有统一的枚举接口(例如 BaseEnum,包含 getCode() 和 getDesc()),可以利用泛型抽取一个公共的转换方法。如果没有,建议在后续工程重构时引入类似 EnumUtil.getByCode(code, EnumClass.class) 的工具类。

    二、评分明细

    • 1. 功能实现的正确性与健壮性(36/40分) 理由:核心业务逻辑(条件判断、字符串拼接)实现正确,StringJoiner 和 Objects.equals 使用规范且空指针安全;未涉及 MyBatis 修改。扣分点在于枚举匹配失败时返回原始 Code,存在边缘场景的展示缺陷,以及潜在的意向等级字段未翻译风险。

    • 2. 安全性与潜在风险(30/30分) 理由:本次变更为纯内存级别的字符串格式化与条件判断,不涉及数据库操作、外部输入直接拼接或敏感信息打印,无安全隐患。

    • 3. 最佳实践与可维护性(18/20分) 理由:代码结构清晰,方法拆分合理,避免了魔法值(使用了 FollowResultEnum.INVITE_INSPECTION.getCode())。扣分点在于枚举转换逻辑略显冗余,未采用更通用的泛型或工具类设计。

    • 4. 性能与资源利用(5/5分) 理由:使用了 StringJoiner 进行字符串拼接,相比于 + 拼接在循环或复杂逻辑中性能更好,资源利用合理。

    • 5. 提交信息质量(5/5分) 理由:Commit 信息采用了标准的 Angular 规范(feat(clues): ...),标题清晰,Body 部分使用列表详细阐述了具体改动点及移除的逻辑,追溯性极佳。

    总分:94分

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