Skip to content
  • Projects
  • Groups
  • Snippets
  • Help

dj / rpc-mindworkplate

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Merged
Merge Request !28 opened Sep 29, 2026 by 叶立庆@yelq

上线合并

v5.8.6.3发起合并请求到master分支

Edited Sep 29, 2026
Request to merge v5.8.6.3 into master
×

Check out, review, and merge locally

Step 1. Fetch and check out the branch for this merge request

git fetch origin
git checkout -b v5.8.6.3 origin/v5.8.6.3

Step 2. Review the changes locally

Step 3. Merge the branch and fix any conflicts that come up

git checkout master
git merge --no-ff v5.8.6.3

Step 4. Push the result of the merge to GitLab

git push origin master

Note that pushing to GitLab requires write access to this repository.

Tip: You can also checkout merge requests locally by following these guidelines.

Merged by 叶立庆 Sep 29, 2026

  • The changes were merged into master.
  • Discussion 1
  • Commits 1
  • Changes 5
  • {{ resolvedDiscussionCount }}/{{ discussionCount }} {{ resolvedCountText }} resolved
  • 2641f1b3da612f8e5cf4541059e216a6?s=80&d=identicon
    Toggle discussion
    王欣伟
    @wangxw1 started a discussion on commit c1038038 Sep 28, 2026
    • @wangxw1 王欣伟
      @wangxw1 commented Sep 28, 2026
      Master

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

      1. 循环内执行数据库查询(严重的性能隐患)

      • 问题描述:在 ResidentPointService.java 的 residentDirectSaleMerchant1Check 方法中,通过 for 循环遍历 merchantIdsStr,并在循环内部频繁调用 residentPointRecordMapper.residentDirectSaleMerchantCheck 进行数据库查询。
      • 影响分析:这是典型的 N+1 查询问题。如果配置的服务商 ID 数量较多,将导致与数据库建立多次网络交互,极大地消耗数据库连接资源并拖慢接口响应时间,甚至可能在高并发下引发连接池耗尽。
      • 优化建议:应将循环查询改为批量查询。在 MyBatis 层新增或修改方法,接收 List<Integer> 参数,使用 IN 关键字一次性查出结果。 代码示例: java // 建议的 Service 层优化逻辑 List<Integer> list = Arrays.stream(merchantIdsStr.split(",")).map(Integer::valueOf).collect(Collectors.toList()); // 建议在 Mapper 中新增支持 List<Integer> 的查询方法,避免在循环中查库 requestDTO.setMainMerchantIdList(list); return !residentPointRecordMapper.residentDirectSaleMerchantCheckBatch(requestDTO).isEmpty();

      2. 异常掩盖与入参对象状态被意外篡改(健壮性缺陷)

      • 问题描述:
        1. 在 ResidentPointService 中,如果抛出了 new RpcServiceException("服务商未配置"),随后会被外层的 catch (Exception e) 捕获,并被强行重新包装为 "门店号是否是直营门店校验数据库查询异常"。
        2. 在循环中使用了 requestDTO.setMainMerchantId(m) 直接修改了传入的 DTO 对象。
      • 影响分析:异常掩盖会导致排查线上问题时日志信息严重误导开发者(明明是没配置,却报数据库异常)。修改入参对象(副作用)违反了无状态编程原则,若上层调用方后续继续使用该 requestDTO,其内部的 mainMerchantId 已经被污染为循环的最后一个值,可能引发难以排查的 Bug。
      • 优化建议:区分异常捕获类型;避免修改入参,可使用局部变量或克隆对象。 代码示例: java } catch (RpcServiceException re) { throw re; // 避免自定义的 RpcServiceException 被掩盖 } catch (Exception e) { log.error("门店直营校验异常", e); throw new RpcServiceException("门店号是否是直营门店校验系统异常"); }

      3. 接口命名极度不规范与遗留无用代码(可维护性问题)

      • 问题描述:新增的 API 接口名为 residentDirectSaleMerchantCheck1Remote,Service 方法名为 residentDirectSaleMerchant1Check。此外,Service 方法中遗留了被注释掉的旧逻辑代码。
      • 影响分析:使用数字 1 作为方法后缀是工程命名中的反模式(Anti-pattern)。这使得调用方完全无法从方法名判断 Check 与 Check1 的业务区别,严重降低代码可读性与可维护性。遗留注释代码会造成代码库的无意义膨胀和视觉干扰。
      • 优化建议:根据业务实际含义重命名,例如该接口是针对“加优加服务商”的,可命名为 residentDirectSaleMerchantPlusCheckRemote 或 checkUPlusDirectSaleMerchantRemote。同时,清理掉被 // 注释掉的无用历史代码。

      二、评分明细

      • 功能实现的正确性与健壮性(32/40分) 扣分理由:虽然业务逻辑可以跑通,且遵守了 Dubbo 接口不修改已有请求参数的规则(采用新增接口的方式),但存在严重的异常掩盖逻辑缺陷,以及对入参 DTO 进行副作用修改的问题,降低了代码的健壮性。

      • 安全性与潜在风险(30/30分) 评分理由:未发现明显的 SQL 注入、越权、XSS 或敏感信息泄露等安全风险。

      • 最佳实践与可维护性(12/20分) 扣分理由:方法命名(后缀加 1)严重违反 Clean Code 命名规范;代码中提交了未清理的注释死代码。

      • 性能与资源利用(2/5分) 扣分理由:在 for 循环中直接进行数据库查询(N+1 反模式),存在明显的性能瓶颈,未合理利用数据库的批量查询能力。

      • 提交信息质量(4/5分) 扣分理由:Commit 信息 "新增判断直营(加优加服务商)接口" 表达了主要意图,但未能解释为何需要新建一个带 1 的接口而不是复用或扩展原有逻辑,缺乏部分上下文。

      总分:80分

  • @yelq 叶立庆
    @yelq

    merged

    Sep 29, 2026

    merged

    Toggle commit list
  • @yelq 叶立庆
    @yelq

    mentioned in commit 902e5bdb

    Sep 29, 2026

    mentioned in commit 902e5bdb

    Toggle commit list
  • Write
  • Preview
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
  • Please register or sign in to post a comment
叶立庆
Assignee
叶立庆 @yelq
Assign to
None
Milestone
None
Assign milestone
Time tracking
1
1 participant
Reference: dj/rpc-mindworkplate!28
×

Revert this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.
×

Cherry-pick this merge request

Switch branch
Cancel
A new branch will be created in your fork and a new merge request will be started.