Commit 975efebb by 林冲

Merge branch 'v5.8.1' into 'main'

上线合并

See merge request !1
2 parents 10a9038c a2a5fffd
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-supervisor-api</artifactId> <artifactId>rpc-dj-supervisor-api</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>5.8.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.supervisor.dto.ExcellentCaseReviewReqDTO; ...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.supervisor.dto.ExcellentCaseReviewReqDTO;
import cn.com.glsx.dj.supervisor.remote.ExcellentCaseReviewRemote; import cn.com.glsx.dj.supervisor.remote.ExcellentCaseReviewRemote;
import cn.com.glsx.dj.supervisor.request.ExcellentCaseReviewQueryRequest; import cn.com.glsx.dj.supervisor.request.ExcellentCaseReviewQueryRequest;
import cn.com.glsx.dj.supervisor.request.ExcellentCaseReviewRequest; import cn.com.glsx.dj.supervisor.request.ExcellentCaseReviewRequest;
import cn.com.glsx.dj.supervisor.request.SupervisorTaskQueryRequest;
import cn.com.glsx.dj.supervisor.utils.CommonUtil; import cn.com.glsx.dj.supervisor.utils.CommonUtil;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
...@@ -64,6 +65,22 @@ public class ExcellentCaseReviewController { ...@@ -64,6 +65,22 @@ public class ExcellentCaseReviewController {
} }
/** /**
* 根据任务ID查询优秀案例列表(分页)
*/
@ServiceMethod(method = "dj.api.supervisor.excellent.case.listByTaskId", needInSession = NeedInSessionType.YES)
@ApiOperation("根据任务ID查询优秀案例列表")
public RopResponse<RpcPagination<ExcellentCaseDetailDTO>> queryExcellentCaseListByTaskId(SupervisorTaskQueryRequest request) {
RpcPagination<ExcellentCaseReviewQueryDTO> pagination = CommonUtil.getRpcPagination(ExcellentCaseReviewQueryDTO.class);
pagination.getCondition().setTaskId(request.getId());
RpcResponse<RpcPagination<ExcellentCaseDetailDTO>> result = excellentCaseReviewRemote.queryExcellentCaseListByTaskId(pagination);
if (result.isSuccess()) {
return RopResponse.success(result.getResult());
} else {
return RopResponse.error(result.getError(), result.getMessage());
}
}
/**
* 查询优秀案例详情 * 查询优秀案例详情
* <p> * <p>
* 根据案例ID查询完整的案例信息,包括案例详情、审核信息等 * 根据案例ID查询完整的案例信息,包括案例详情、审核信息等
......
...@@ -153,8 +153,19 @@ public class SupervisorTaskInfoController { ...@@ -153,8 +153,19 @@ public class SupervisorTaskInfoController {
return RopResponse.success(result); return RopResponse.success(result);
} }
/**
* 分页查询带教列表
*/
@ServiceMethod(method = "dj.api.supervisor.page.teachingRecords", needInSession = NeedInSessionType.YES)
@ApiOperation("分页查询带教列表")
public RopResponse<RpcPagination<SupervisorTeachingListDTO>> pageTeachingRecords(SupervisorTaskQueryRequest request) {
RpcPagination<SupervisorTaskQueryDTO> pagination = CommonUtil.getRpcPagination(SupervisorTaskQueryDTO.class);
RpcResponse<RpcPagination<SupervisorTeachingListDTO>> response = supervisorTaskInfoRemote.pageTeachingRecords(pagination);
if (response.hasError()) {
return RopResponse.error(response.getError(), response.getMessage());
} else {
return RopResponse.success(response.getResult());
}
}
} }
  • @wangxw1
    commented
    Master

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

    1. 【功能正确性】pageTeachingRecords 方法中入参 request 完全未被使用(严重缺陷)

    • 问题描述:在 SupervisorTaskInfoController.java 的 pageTeachingRecords 方法中,接收了客户端传来的 SupervisorTaskQueryRequest request 参数,但在构建 pagination 对象并调用远程服务时,完全没有将 request 中的任何属性(如查询条件、页码、每页条数等)赋值给 pagination。这会导致客户端传递的查询和分页条件全部失效,接口永远只能根据空条件和默认分页进行查询。
    • 优化建议:在调用远程服务前,必须将 request 中的参数映射到 pagination 对象中。 java RpcPagination<SupervisorTaskQueryDTO> pagination = CommonUtil.getRpcPagination(SupervisorTaskQueryDTO.class); // 补充参数映射逻辑,例如: pagination.setPageNum(request.getPageNum()); pagination.setPageSize(request.getPageSize()); // 如果 request 中有其他查询条件也需要一并赋值 RpcResponse<RpcPagination<SupervisorTeachingListDTO>> response = supervisorTaskInfoRemote.pageTeachingRecords(pagination);

    2. 【规范与可维护性】正式发布分支(main)中使用了 SNAPSHOT 快照版本依赖

    • 问题描述:根据提交信息 Merge branch 'v5.8.1' into 'main' 和 上线合并 可以看出,这是准备发布到生产环境的代码。但在 pom.xml 中,rpc-dj-supervisor-api 的版本号被修改为了 5.8.1-SNAPSHOT。《阿里巴巴 Java 开发手册》明确规定:正式发布的类库必须先升级为正式版本号,不允许在正式发布环境中使用 SNAPSHOT 版本。SNAPSHOT 是不稳定版本,随时可能被覆盖,会导致生产环境出现不可预知的 Bug 且难以溯源。
    • 优化建议:在合并到 main 分支并发布上线前,必须将 pom.xml 中的版本号修改为正式版本(如 5.8.1 或 5.8.1.RELEASE)。

    3. 【功能正确性】queryExcellentCaseListByTaskId 分页参数存在丢失风险

    • 问题描述:在 ExcellentCaseReviewController.java 中,方法注释明确写明是“分页”查询,代码中也只映射了 taskId (pagination.getCondition().setTaskId(request.getId());)。与问题 1 类似,这里没有显式传递分页参数(如 pageNum, pageSize)。除非 CommonUtil.getRpcPagination 内部通过 RequestContextHolder 等隐式方式从当前请求上下文中强行抓取了分页参数(这种隐式耦合设计本身也不符合最佳实践),否则会导致客户端传来的分页参数失效。
    • 优化建议:显式地将请求中的分页参数传递给 RPC 分页对象,保证数据流转的清晰和正确性: java RpcPagination<ExcellentCaseReviewQueryDTO> pagination = CommonUtil.getRpcPagination(ExcellentCaseReviewQueryDTO.class); pagination.getCondition().setTaskId(request.getId()); // 建议显式设置分页参数 pagination.setPageNum(request.getPageNum()); pagination.setPageSize(request.getPageSize());

    二、评分明细

    评审维度 权重 得分 扣分说明
    1. 功能实现的正确性与健壮性 40分 20分 扣20分。pageTeachingRecords 方法完全遗漏了入参映射,属于严重的业务功能失效 Bug(扣15分);queryExcellentCaseListByTaskId 遗漏分页参数映射(扣5分)。
    2. 安全性与潜在风险 30分 30分 满分。本次代码变更主要为内部 RPC 调用和 DTO 组装,未见明显的 SQL 注入、越权等直接安全漏洞。
    3. 最佳实践与可维护性 20分 10分 扣10分。违反阿里开发规范,在代表生产环境的 main 分支合并(上线合并)中包含了 SNAPSHOT 不稳定版本依赖。
    4. 性能与资源利用 5分 5分 满分。常规的 Controller 层调用,无明显性能瓶颈或资源浪费。
    5. 提交信息质量 5分 4分 扣1分。Commit 信息基本清晰(注明了功能和修改人),但在上线合并的 Commit 中携带了未清理的 SNAPSHOT 依赖,说明发布流程的 Review 机制存在瑕疵。

    总分:69分

  • @wangxw1
    commented
    Master

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

    1. 功能缺陷:SupervisorTaskInfoController 中请求参数被完全忽略(严重)

    • 问题描述:在 pageTeachingRecords 方法中,接收了 SupervisorTaskQueryRequest request 参数,但在构建 RpcPagination 后,完全没有将 request 中的查询条件(如分页参数 pageNum/pageSize、查询条件等)赋值给 pagination 对象,直接将其传给了 RPC 接口。这将导致该接口的分页和条件查询功能完全失效,永远只能查询默认条件的数据。
    • 优化建议:将 request 中的参数正确映射到 pagination 中。 java RpcPagination<SupervisorTaskQueryDTO> pagination = CommonUtil.getRpcPagination(SupervisorTaskQueryDTO.class); // 补充参数映射,例如: // pagination.setPageNum(request.getPageNum()); // pagination.setPageSize(request.getPageSize()); // pagination.getCondition().setTaskId(request.getId());

    2. 生产发布风险:pom.xml 在主分支/上线合并中引入 SNAPSHOT 版本(高危)

    • 问题描述:根据提交记录 Merge branch 'v5.8.1' into 'main' 上线合并 可以看出,这是准备发布上线的代码。但在 pom.xml 中,将 rpc-dj-supervisor-api 的版本修改为了 5.8.1-SNAPSHOT。《阿里巴巴 Java 开发手册》明确规定:正式发布的类库必须先升级为 Release 版本号,绝对不允许在正式发布(生产环境)的代码中依赖 SNAPSHOT 版本。 SNAPSHOT 版本是不稳定的,随时可能被覆盖,会导致生产环境出现不可预知的 Bug。
    • 优化建议:在合并到 main 分支上线前,必须将 pom.xml 中的依赖版本修改为正式的 Release 版本(例如 5.8.1)。

    3. 健壮性缺失:ExcellentCaseReviewController 存在潜在的空指针异常(NPE)风险(中危)

    • 问题描述:在 queryExcellentCaseListByTaskId 方法中,存在链式调用和直接获取参数的操作:pagination.getCondition().setTaskId(request.getId());。这里存在两个 NPE 隐患:
      1. 方法未对入口参数 request 进行校验,如果前端少传或错传导致 request 为 null,调用 request.getId() 会直接引发 NPE。
      2. 假设 CommonUtil.getRpcPagination 没有为 Condition 初始化默认实例,pagination.getCondition() 将返回 null,后续调用 setTaskId 也会引发 NPE。
    • 优化建议:遵循《阿里巴巴 Java 开发手册》关于防御性编程的规范,添加判空或使用 Validation 注解。 java if (request == null || request.getId() == null) { return RopResponse.error("参数错误", "任务ID不能为空"); } RpcPagination<ExcellentCaseReviewQueryDTO> pagination = CommonUtil.getRpcPagination(ExcellentCaseReviewQueryDTO.class); if (pagination.getCondition() == null) { pagination.setCondition(new ExcellentCaseReviewQueryDTO()); } pagination.getCondition().setTaskId(request.getId());

    二、评分明细

    • 1. 功能实现的正确性与健壮性(40分):22分
      • 扣分原因:带教列表接口完全遗漏了请求参数的装配,导致分页和查询功能失效(-13分);查询优秀案例接口缺少基本的参数判空和防御性编程,存在 NPE 风险(-5分)。
    • 2. 安全性与潜在风险(30分):20分
      • 扣分原因:生产环境(main分支上线)代码中包含了 SNAPSHOT 快照版本的依赖,违反发布规范,存在极大的生产环境运行不一致风险(-10分)。
    • 3. 最佳实践与可维护性(20分):18分
      • 扣分原因:Controller 层缺少 @Valid 或 @Validated 等标准化参数校验机制,依赖手动处理或未处理(-2分)。
    • 4. 性能与资源利用(5分):5分
      • 得分原因:RPC 调用和分页对象的创建符合常规模式,无明显性能瓶颈。
    • 5. 提交信息质量(5分):4分
      • 扣分原因:Commit 信息虽然说明了意图(如“上线合并”),但与实际代码变更(提交 SNAPSHOT)存在矛盾,审查不够严谨(-1分)。

    总分:69分

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