Commit 4c412f52 by zhouhaibao

新增督导分页查询处理

1 parent 7cef732e
...@@ -569,12 +569,12 @@ public class SupervisorDashboardController { ...@@ -569,12 +569,12 @@ public class SupervisorDashboardController {
*/ */
@ServiceMethod(method = "dj.api.supervisor.management.supervisor.performance", needInSession = NeedInSessionType.NO) @ServiceMethod(method = "dj.api.supervisor.management.supervisor.performance", needInSession = NeedInSessionType.NO)
@ApiOperation("业绩概览 -- 督导业绩接口(总部运营视角)") @ApiOperation("业绩概览 -- 督导业绩接口(总部运营视角)")
public RopResponse<List<SupervisorPerformanceDTO>> getSupervisorPerformance(SupervisorPerformanceRequest request) { public RopResponse<SupervisorPerformanceResponse> getSupervisorPerformance(SupervisorPerformanceRequest request) {
log.info("业绩概览 -- 督导业绩接口:{}", request); log.info("业绩概览 -- 督导业绩接口:{}", request);
try { try {
SupervisorManagementQueryReq req = CommonUtil.convertRequest(SupervisorManagementQueryReq.class); SupervisorManagementQueryReq req = CommonUtil.convertRequest(SupervisorManagementQueryReq.class);
RpcResponse<List<SupervisorPerformanceDTO>> result = supervisorDashboardRemote.getSupervisorPerformance(req); RpcResponse<SupervisorPerformanceResponse> result = supervisorDashboardRemote.getSupervisorPerformance(req, request.getPage());
return convertRpcResponse(result); return convertRpcResponse(result);
} catch (RpcServiceException e) { } catch (RpcServiceException e) {
log.error("Controller__invoke__getSupervisorPerformance__bizException:{}", e.getMessage(), e); log.error("Controller__invoke__getSupervisorPerformance__bizException:{}", e.getMessage(), e);
......
...@@ -33,4 +33,7 @@ public class SupervisorPerformanceRequest extends AbstractRopRequest { ...@@ -33,4 +33,7 @@ public class SupervisorPerformanceRequest extends AbstractRopRequest {
@NotNull @NotNull
private Integer statDimension; private Integer statDimension;
@ApiModelProperty(notes = "页码(从0开始,固定每页3条)", example = "0")
private Integer page;
} }
\ No newline at end of file \ No newline at end of file
  • @wangxw1
    commented
    Master

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

    1. 安全性:敏感业务接口未强制要求会话登录(高危)

    • 问题描述:在 SupervisorDashboardController 中,getSupervisorPerformance 接口的注解配置为 @ServiceMethod(..., needInSession = NeedInSessionType.NO)。该接口明确标注为“总部运营视角”的“业绩概览”,属于高度敏感的商业数据。如果网关层没有额外的鉴权拦截,配置为 NO 将导致未授权的用户甚至外部人员可以直接匿名访问该接口,存在严重的数据泄露风险。
    • 优化建议:除非该接口仅供内部微服务在无上下文中调用(通常不会在 Controller 层暴露),否则必须将配置修改为 needInSession = NeedInSessionType.YES,强制校验用户登录态与数据权限。

    2. 功能健壮性:新增的分页参数缺乏基础校验(易引发 NPE 或越界)

    • 问题描述:在 SupervisorPerformanceRequest 中新增了 Integer page 参数,但未添加任何 JSR-303 校验注解。由于它是包装类型 Integer,客户端若未传该字段,其值为 null。当 request.getPage() 被传递给下游 RPC 服务时,如果下游直接进行拆箱(转换为 int)或未做空指针处理,将直接引发 NullPointerException。此外,客户端可能传入负数(如 -1),导致底层 SQL 报错。
    • 优化建议:根据《阿里巴巴 Java 开发手册》关于参数校验的规范,外部输入的参数必须进行校验。建议补充注解: java @NotNull(message = "页码不能为空") @Min(value = 0, message = "页码不能小于0") @ApiModelProperty(notes = "页码(从0开始,固定每页3条)", example = "0", required = true) private Integer page;

    3. 可维护性与设计规范:分页参数传递与设计不优雅

    • 问题描述:
      1. 硬编码问题:API 注释中写明“固定每页3条”,这种将分页大小(pageSize)硬编码在业务逻辑或注释中的做法违背了开闭原则,后续若需调整为每页5条,必须修改前后端代码。
      2. 参数传递割裂:CommonUtil.convertRequest 将请求转换为了 req,但随后调用 RPC 时却单独把 request.getPage() 作为第二个参数传入(getSupervisorPerformance(req, request.getPage()))。这说明底层 SupervisorManagementQueryReq 并未包含分页信息,导致领域模型不够内聚。
    • 优化建议:建议引入标准的分页请求基类(包含 page 和 pageSize),让 SupervisorPerformanceRequest 继承它。同时将分页参数整合进 SupervisorManagementQueryReq 对象中统一传递,避免方法签名随着参数增加而不断膨胀。

    二、评分明细

    评审维度 得分 满分 扣分原因/评价
    1. 功能正确性与健壮性 28 40 新增参数 page 缺失 @NotNull 和 @Min 校验,存在潜在的 NPE 和非法参数(负数)越界风险。
    2. 安全性与潜在风险 15 30 核心运营数据接口配置为无需 Session(NeedInSessionType.NO),存在极高的数据越权/泄露风险(若无网关兜底)。
    3. 最佳实践与可维护性 14 20 分页大小硬编码;且 RPC 方法参数传递存在割裂感(Query对象与Page参数分离),不符合面向对象封装原则。
    4. 性能与资源利用 5 5 变更内容未引入明显的性能瓶颈或资源浪费,RPC 响应泛型修改正确。
    5. 提交信息质量 4 5 提交信息“新增督导分页查询处理”描述清晰,但未能涵盖返回值结构变更(DTO 转 Response)的说明。

    总分:66分

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