Commit 7b94d9b4 by 章家宝

fixbug:修改测试环境的提成方案审批地址

1 parent 81849354
...@@ -200,7 +200,7 @@ public class PerformanceConfigApproveService { ...@@ -200,7 +200,7 @@ public class PerformanceConfigApproveService {
String agentId = env.getProperty("performance.approve.send.qw.notice.agentId", String.class,"1000024"); String agentId = env.getProperty("performance.approve.send.qw.notice.agentId", String.class,"1000024");
String titleEnv = env.getProperty("performance.approve.send.qw.notice.title", String.class, "门店提成方案%s审批提醒"); String titleEnv = env.getProperty("performance.approve.send.qw.notice.title", String.class, "门店提成方案%s审批提醒");
String descriptionEvn = env.getProperty("performance.approve.send.qw.notice.description", String.class, "%s#%s#发起内容%s申请,请相关领导审批查阅。"); String descriptionEvn = env.getProperty("performance.approve.send.qw.notice.description", String.class, "%s#%s#发起内容%s申请,请相关领导审批查阅。");
String urlEvn = env.getProperty("performance.approve.send.qw.notice.url", String.class, "https://scrm.test.glsx.com.cn/recruitment/#/salary/index?corpId=wwa55ffac1225eb25e&agentId=1000002&phone=%s&id=%s"); String urlEvn = env.getProperty("performance.approve.send.qw.notice.url", String.class, "https://scrm.test.glsx.com.cn/recruitment/#/salary?corpId=wwa55ffac1225eb25e&agentId=1000002&phone=%s&id=%s");
String userId = qwManager.getUserId(merchantId, performanceApproveConfigDTO.getApproverMobile()); String userId = qwManager.getUserId(merchantId, performanceApproveConfigDTO.getApproverMobile());
if (StringUtils.isBlank(userId)) { if (StringUtils.isBlank(userId)) {
return false; return false;
...@@ -218,7 +218,7 @@ public class PerformanceConfigApproveService { ...@@ -218,7 +218,7 @@ public class PerformanceConfigApproveService {
String url = String.format(urlEvn, performanceApproveConfigDTO.getApproverMobile(), performanceConfigApproveId); String url = String.format(urlEvn, performanceApproveConfigDTO.getApproverMobile(), performanceConfigApproveId);
textCard.setTitle(title); textCard.setTitle(title);
textCard.setDescription(description); textCard.setDescription(description);
textCard.setUrl(urlEvn); textCard.setUrl(url);
requestDTO.setTextCard(textCard); requestDTO.setTextCard(textCard);
SendWorkWechatMessageResponseDTO responseDTO = null; SendWorkWechatMessageResponseDTO responseDTO = null;
try { try {
......
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
<if test="updatedBy != null and updatedBy != ''"> <if test="updatedBy != null and updatedBy != ''">
updated_by = #{updatedBy}, updated_by = #{updatedBy},
</if> </if>
<if test="approveDate != null and approveDate != ''"> <if test="approveDate != null">
approve_date = #{approveDate}, approve_date = #{approveDate},
</if> </if>
updated_date = NOW() updated_date = NOW()
......
  • @wangxw1
    commented
    Master

    你好。我是资深的软件开发工程师,针对你本次提交的代码(涉及企业微信通知逻辑修复及 MyBatis 配置优化),以下是我的代码审查反馈:

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

    1. 敏感信息硬编码与安全风险

      • 问题描述:在 PerformanceConfigApproveService.java 中,urlEvn 的默认值硬编码了 corpId(wwa55ff...)和 agentId。
      • 影响分析:将企业敏感凭据硬编码在源码中,不仅增加了泄露风险,还导致代码在不同环境(开发、测试、生产)之间的迁移变得困难。一旦企业 ID 变更,必须修改代码并重新发布。
      • 优化建议:应将完整的 URL 模板配置在 apollo、nacos 或 application.yml 中,代码中仅保留 Key 的读取,不建议提供包含敏感信息的默认值。 java // 建议方案:仅读取配置,若为空则抛出异常或记录告警,而非硬编码默认 URL String urlTemplate = env.getProperty("performance.approve.send.qw.notice.url"); if (StringUtils.isBlank(urlTemplate)) { log.error("未配置审批提醒跳转地址"); return false; }
    2. 硬编码默认值导致的可维护性问题

      • 问题描述:方法内部存在大量硬编码的字符串默认值(如 agentId "1000024"、标题模板、描述模板等)。
      • 影响分析:业务逻辑与配置信息高度耦合。当产品需求调整通知文案时,开发人员需要深入业务代码定位并修改,违反了“配置与代码分离”的原则。
      • 优化建议:建议将这些默认值定义为类的静态常量(private static final),或者封装到一个专门的 Config 配置类中。
    3. 变量命名拼写错误(Typo)

      • 问题描述:代码中多次出现 descriptionEvn 和 urlEvn。
      • 影响分析:显然是 Env(Environment)的误拼写。虽然不影响功能,但降低了代码的专业性,且在后续全局搜索或代码重构时可能导致遗漏。
      • 优化建议:将 descriptionEvn 修改为 descriptionEnv,将 urlEvn 修改为 urlEnv。

    二、评分明细

    • 功能实现的正确性与健壮性(40分):40分。正确修复了 textCard.setUrl 误传模板字符串的 Bug;同时修正了 MyBatis 中对日期类型进行空字符串 '' 判断的潜在风险(Date 类型与空串比较在 MyBatis 中可能引发异常)。
    • 安全性与潜在风险(30分):22分。扣分项主要在于源码中硬编码了企业的 corpId 等敏感标识信息。
    • 最佳实践与可维护性(20分):14分。变量命名存在拼写错误,且配置项默认值散落在业务逻辑方法中,未实现良好的配置管理。
    • 性能与资源利用(5分):5分。该变更不涉及性能瓶颈。
    • 提交信息质量(5分):3分。提交信息 fixbug 过于笼统,未能体现出同时修复了 URL 赋值逻辑和 MyBatis 日期判断逻辑这两个不同维度的变更。

    三、总分

    总分:84分

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