Commit 493d1fe9 by 崔彦峰

fix(goods): 修正上架ID验证错误提示信息

- 修正了商品上架ID验证时的错误提示文本
- 将错误信息从"不属于当前门店商品上架ID列表"改为"不属于当前门店已上架ID列表"
- 修正了套餐上架ID验证时的错误提示文本
- 将错误信息从"不属于当前门店套餐上架ID列表"改为"不属于当前门店套餐已上架ID列表"
1 parent 002ba564
...@@ -1285,7 +1285,7 @@ public class GoodsListingSubmitService { ...@@ -1285,7 +1285,7 @@ public class GoodsListingSubmitService {
for (Map.Entry<Integer, String> entry : modifyGoodsCodes.entrySet()) { for (Map.Entry<Integer, String> entry : modifyGoodsCodes.entrySet()) {
if (!currentMerchantGoodsCodes.contains(entry.getValue())) { if (!currentMerchantGoodsCodes.contains(entry.getValue())) {
invalidLeaderIndexes.add(entry.getKey()); invalidLeaderIndexes.add(entry.getKey());
setLineError(errorList, "原上架ID" + entry.getValue() + "不属于当前门店商品上架ID列表", entry.getKey()); setLineError(errorList, "原上架ID" + entry.getValue() + "不属于当前门店已上架ID列表", entry.getKey());
} }
} }
} }
...@@ -1309,7 +1309,7 @@ public class GoodsListingSubmitService { ...@@ -1309,7 +1309,7 @@ public class GoodsListingSubmitService {
for (Map.Entry<Integer, String> entry : modifyPackageCodes.entrySet()) { for (Map.Entry<Integer, String> entry : modifyPackageCodes.entrySet()) {
if (!currentMerchantPackageCodes.contains(entry.getValue())) { if (!currentMerchantPackageCodes.contains(entry.getValue())) {
invalidLeaderIndexes.add(entry.getKey()); invalidLeaderIndexes.add(entry.getKey());
setLineError(errorList, "原上架ID" + entry.getValue() + "不属于当前门店套餐上架ID列表", entry.getKey()); setLineError(errorList, "原上架ID" + entry.getValue() + "不属于当前门店套餐已上架ID列表", entry.getKey());
} }
} }
} }
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    1. 字符串拼接可读性与规范性优化

    • 问题描述:在生成错误提示信息时,代码直接使用了加号(+)进行字符串的硬编码拼接(如 "原上架ID" + entry.getValue() + "不属于...")。
    • 影响分析:虽然此处属于异常分支,对系统性能影响微乎其微,但这种字符串拼接方式在一定程度上降低了代码的可读性,且不利于后续文案的统一管理与维护。
    • 优化建议:建议使用 String.format 进行字符串格式化,使代码结构更清晰、更优雅。

    代码示例:

    // 优化前
    setLineError(errorList, "原上架ID" + entry.getValue() + "不属于当前门店已上架ID列表", entry.getKey());
    
    // 优化后
    setLineError(errorList, String.format("原上架ID[%s]不属于当前门店已上架ID列表", entry.getValue()), entry.getKey());
    

    (注:本次提交代码变更极小且逻辑简单,除上述代码风格优化外,未发现其他功能、安全及性能问题。)

    二、评分明细

    • 功能实现的正确性与健壮性(40分):40分。本次变更为纯文案修改,未改变原有核心业务逻辑,未违反 Mybatis 子查询及 Dubbo 接口参数变更等重要规则,功能正确。
    • 安全性与潜在风险(30分):30分。仅涉及本地字符串的修改与赋值,不存在 SQL 注入、XSS、越权或敏感信息泄露等安全隐患。
    • 最佳实践与可维护性(20分):18分。代码逻辑清晰,但异常提示信息的字符串拼接方式可进一步采用 String.format 优化以提升可读性和可维护性。
    • 性能与资源利用(5分):5分。异常处理分支的少量字符串拼接不会造成性能瓶颈,资源利用合理。
    • 提交信息质量(5分):5分。Commit 遵循了常规的规范(fix(goods): ...),详细且准确地描述了修改的内容及原因,具有很好的可追溯性。

    总分:98分

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