Commit 3bba41c9 by 叶立庆

Merge branch 'v5.8.5' into 'master'

上线合并

See merge request !14
2 parents 3057bd27 449cb41f
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
<dependency> <dependency>
<groupId>com.gsc4cloud</groupId> <groupId>com.gsc4cloud</groupId>
<artifactId>gsc-vcp-api</artifactId> <artifactId>gsc-vcp-api</artifactId>
<version>1.1.1-SNAPSHOT</version> <version>1.1.2-SNAPSHOT</version>
</dependency> </dependency>
<!--feign 调用--> <!--feign 调用-->
<dependency> <dependency>
......
package com.gsc4cloud.gsc.facade.vpcweb.controller.clues;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gsc4cloud.gsc.common.core.util.R;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesPageResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesDetailResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesFollowRecordListResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesFollowTimeStatusCountResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesMerchantPageResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesOperationLogListResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesStatusCountResp;
import com.gsc4cloud.gsc.vpc.api.feign.pad.clues.CluesRemote;
import com.gsc4cloud.gsc.vpc.api.req.PageRequest;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesFollowRecordListReq;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesFollowTimeStatusCountReq;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesStatusCountReq;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesDetailReq;
import com.gsc4cloud.gsc.vpc.api.req.pad.evalorder.EvalOrderPageRequest;
import com.gsc4cloud.gsc.vpc.api.req.web.clues.CluesWebPageReq;
import com.gsc4cloud.gsc.vpc.api.req.web.clues.CluesOperationLogListReq;
import com.gsc4cloud.gsc.vpc.api.req.web.clues.CluesMerchantPageReq;
import com.gsc4cloud.gsc.facade.vpcweb.anotation.RopSession;
import com.gsc4cloud.gsc.facade.vpcweb.response.rop.LoginAccountResponse;
import com.gsc4cloud.gsc.facade.vpcweb.response.rop.LoginUserInfoResponse;
import com.gsc4cloud.gsc.facade.vpcweb.utils.ThreadLocalCache;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Arrays;
import java.util.List;
@Tag(name = "WEB端-二手车线索管理")
@RestController
@RequestMapping("/clues")
public class CluesController {
@Autowired
private CluesRemote cluesRemote;
@Autowired
private Environment env;
@RopSession
@Operation(summary = "WEB端线索分页列表")
@PostMapping("/page")
public R<Page<CluesPageResp>> page(@RequestBody @Validated PageRequest<CluesWebPageReq> req) {
return cluesRemote.webPage(req);
}
@RopSession
@Operation(summary = "WEB端线索状态数量统计")
@PostMapping("/statusCount")
public R<CluesStatusCountResp> statusCount(@RequestBody @Validated CluesStatusCountReq req) {
return cluesRemote.statusCount(req);
}
@RopSession
@Operation(summary = "WEB端线索跟进时间状态数量统计")
@PostMapping("/followTimeStatusCount")
public R<CluesFollowTimeStatusCountResp> followTimeStatusCount() {
return cluesRemote.followTimeStatusCount(new CluesFollowTimeStatusCountReq());
}
@RopSession
@Operation(summary = "WEB端线索详情")
@PostMapping("/detail")
public R<CluesDetailResp> detail(@RequestBody @Validated CluesDetailReq req) {
return cluesRemote.detail(req);
}
@RopSession
@Operation(summary = "WEB端线索跟进记录列表")
@PostMapping("/followRecord/list")
public R<List<CluesFollowRecordListResp>> followRecordList(
@RequestBody @Validated CluesFollowRecordListReq req) {
return cluesRemote.followRecordList(req);
}
@RopSession
@Operation(summary = "WEB端线索操作日志列表")
@PostMapping("/operationLog/list")
public R<List<CluesOperationLogListResp>> operationLogList(
@RequestBody @Validated CluesOperationLogListReq req) {
return cluesRemote.operationLogList(req);
}
@RopSession
@Operation(summary = "WEB端线索门店分页列表")
@PostMapping("/merchantPage")
public R<Page<CluesMerchantPageResp>> merchantPage(
@RequestBody @Validated PageRequest<CluesMerchantPageReq> req) {
return cluesRemote.merchantPage(req);
}
@Operation(summary = "WEB端线索异步导出")
@RopSession
@PostMapping("/exportAsync")
public R<String> exportAsync(@RequestBody @Validated CluesWebPageReq req) {
CluesWebPageReq request = req == null ? new CluesWebPageReq() : req;
PageRequest<CluesWebPageReq> param = new PageRequest<>(1,
env.getProperty("gsc.vpc.web.export.max.page.size", Integer.class, 10000));
param.setLoginAccout(ThreadLocalCache.getLoginAccountInfo().getLoginAccout());
param.setT(request);
return cluesRemote.exportAsync(param);
}
}
  • @wangxw1
    commented
    Master

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

    1. 依赖管理规范问题:生产环境严禁使用 SNAPSHOT 版本(安全性与潜在风险)

    • 问题描述:在 pom.xml 中,gsc-vcp-api 的版本被升级为 1.1.2-SNAPSHOT。从提交记录 Merge branch 'v5.8.5' into 'master' 上线合并 可以看出,该代码即将发布到生产环境。
    • 规范依据:根据《阿里巴巴 Java 开发手册》,【强制】 二方库版本号命名方式:线上应用不要依赖 SNAPSHOT 版本,保证发布的安全与稳定。SNAPSHOT 版本是动态的,会导致不同时间构建出的产物不一致,极易引发生产故障。
    • 优化建议:在合并到 master 分支并准备上线前,必须将 pom.xml 中的 1.1.2-SNAPSHOT 修改为正式的 Release 版本(如 1.1.2)。

    2. 代码健壮性与 NPE 隐患:exportAsync 方法逻辑缺陷(功能实现的正确性与健壮性)

    • 问题描述:
      1. NPE 风险:ThreadLocalCache.getLoginAccountInfo().getLoginAccout() 存在链式调用。如果当前请求没有经过登录拦截器(或拦截器出现异常导致 ThreadLocal 为空),getLoginAccountInfo() 将返回 null,进而引发 NullPointerException。
      2. 参数接收逻辑矛盾:方法签名为 @RequestBody @Validated CluesWebPageReq req,Spring 默认 @RequestBody 是必传的(required = true)。如果前端不传 body,Spring 会直接抛出 HttpMessageNotReadableException,代码里的 req == null ? new CluesWebPageReq() : req 判空逻辑实际上永远无法被执行到。
    • 优化建议:
      1. 增加 Null-Check:LoginUserInfoResponse userInfo = ThreadLocalCache.getLoginAccountInfo(); if(userInfo != null) { param.setLoginAccout(userInfo.getLoginAccout()); }。
      2. 如果允许请求体为空,需显式声明:@RequestBody(required = false)。

    3. 编码规范问题:无用导入与不推荐的依赖注入方式(最佳实践与可维护性)

    • 问题描述:
      1. 无用导入:文件中存在大量未使用的类导入,例如 java.util.Arrays、org.apache.commons.lang3.StringUtils、EvalOrderPageRequest、LoginAccountResponse 等。
      2. 字段注入:使用了 @Autowired 注解在私有字段(Field Injection)上进行依赖注入。
    • 规范依据:
      1. 根据《阿里巴巴 Java 开发手册》,【强制】 去掉未使用的 import 设置,保持代码整洁。
      2. Spring 官方强烈不推荐使用字段注入,建议使用构造器注入(Constructor Injection),以保证依赖的不可变性(final),并避免潜在的循环依赖和测试困难。
    • 优化建议:
      1. 清理无用的 import 语句。
      2. 推荐使用 @RequiredArgsConstructor (Lombok) 并将 cluesRemote 和 env 声明为 private final,或者手动编写构造方法进行注入。

    二、评分明细

    评审项 满分 得分 扣分说明
    1. 功能实现的正确性与健壮性 40 33 exportAsync 方法存在明显的空指针隐患及 @RequestBody 默认行为导致的死代码逻辑(-7分)。
    2. 安全性与潜在风险 30 20 准备上线(master)的分支中引入了 SNAPSHOT 动态依赖,存在严重的构建不一致风险(-10分)。
    3. 最佳实践与可维护性 20 16 存在未清理的无效 import 语句;使用了不推荐的 Field Injection 方式(-4分)。
    4. 性能与资源利用 5 5 Controller 层主要作为路由转发,无明显性能瓶颈,资源利用合理(-0分)。
    5. 提交信息质量 5 5 提交记录清晰,采用了 Conventional Commits 规范(feat/fix/chore),详细描述了变更点(-0分)。

    总分:79分

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