Commit 7c2a1dae by 叶立庆

Merge branch 'v5.8.5' into 'master'

上线合并

See merge request !12
2 parents 5b1516b4 acdaad52
...@@ -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.0-SNAPSHOT</version> <version>1.1.2-SNAPSHOT</version>
</dependency> </dependency>
<!--feign 调用--> <!--feign 调用-->
<dependency> <dependency>
......
package com.gsc4cloud.gsc.facade.vpcpad.controller.clues;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gsc4cloud.gsc.common.core.util.R;
import com.gsc4cloud.gsc.facade.vpcpad.anotation.RopSession;
import com.gsc4cloud.gsc.facade.vpcpad.response.rop.LoginAccountResponse;
import com.gsc4cloud.gsc.facade.vpcpad.response.rop.LoginUserInfoResponse;
import com.gsc4cloud.gsc.facade.vpcpad.utils.ThreadLocalCache;
import com.gsc4cloud.gsc.vpc.api.exception.BusinessException;
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.CluesStatusCountResp;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.AddCluesReq;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.AddCluesFollowRecordReq;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.AddCluesResp;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesPadPageReq;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesDetailReq;
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.PageRequest;
import com.gsc4cloud.gsc.vpc.api.feign.pad.clues.CluesRemote;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.util.StringUtils;
import java.util.List;
@Tag(name = "PAD端-二手车线索管理")
@RestController
@RequestMapping("/clues")
public class CluesController {
@Autowired
private CluesRemote cluesRemote;
@Operation(summary = "新增线索")
@PostMapping("/add")
public R<AddCluesResp> addClues(@RequestBody @Validated AddCluesReq req) {
return cluesRemote.addClues(req);
}
@Operation(summary = "PAD端新增线索跟进记录")
@PostMapping("/followRecord/add")
@RopSession
public R<Integer> addFollowRecord(@RequestBody @Validated AddCluesFollowRecordReq req) {
fillOperator(req);
return cluesRemote.addFollowRecord(req);
}
private void fillOperator(AddCluesFollowRecordReq req) {
LoginUserInfoResponse loginInfo = ThreadLocalCache.getLoginInfo();
if (loginInfo != null && StringUtils.hasText(loginInfo.getUuid())
&& StringUtils.hasText(loginInfo.getName())) {
req.setOperatorId(loginInfo.getUuid());
req.setOperatorName(loginInfo.getName());
}
if (!StringUtils.hasText(req.getOperatorId()) || !StringUtils.hasText(req.getOperatorName())) {
throw new BusinessException("操作人信息不能为空");
}
}
@Operation(summary = "PAD端线索详情")
@PostMapping("/detail")
public R<CluesDetailResp> detail(@RequestBody @Validated CluesDetailReq req) {
return cluesRemote.detail(req);
}
@Operation(summary = "PAD端线索状态数量统计")
@PostMapping("/statusCount")
public R<CluesStatusCountResp> statusCount(@RequestBody @Validated CluesStatusCountReq req) {
return cluesRemote.statusCount(req);
}
@RopSession
@Operation(summary = "PAD端线索跟进时间状态数量统计")
@PostMapping("/followTimeStatusCount")
public R<CluesFollowTimeStatusCountResp> followTimeStatusCount(
@RequestBody @Validated CluesFollowTimeStatusCountReq req) {
return cluesRemote.followTimeStatusCount(req);
}
@Operation(summary = "PAD端线索跟进记录列表")
@PostMapping("/followRecord/list")
public R<List<CluesFollowRecordListResp>> followRecordList(
@RequestBody @Validated CluesFollowRecordListReq req) {
return cluesRemote.followRecordList(req);
}
@Operation(summary = "PAD端线索分页列表")
@PostMapping("/page")
public R<Page<CluesPageResp>> page(@RequestBody @Validated PageRequest<CluesPadPageReq> req) {
return cluesRemote.padPage(req);
}
}
package com.gsc4cloud.gsc.facade.vpcpad.controller.staff;
import com.gsc4cloud.gsc.common.core.util.R;
import com.gsc4cloud.gsc.facade.vpcpad.anotation.RopSession;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.staff.StaffSceneMerchantResp;
import com.gsc4cloud.gsc.vpc.api.feign.pad.common.StaffRemote;
import com.gsc4cloud.gsc.vpc.api.req.pad.staff.StaffSceneMerchantReq;
import com.gsc4cloud.gsc.vpc.api.req.PageRequest;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
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;
/**
* PAD端-员工管理
*/
@Tag(name = "PAD端-员工管理")
@RestController
@RequestMapping("/staff")
public class StaffController {
@Autowired
private StaffRemote staffRemote;
@Operation(summary = "查询该商户对应园区店的所有驻店员工")
@PostMapping("/listSceneMerchantStaff")
public R<Page<StaffSceneMerchantResp>> listSceneMerchantStaff(@RequestBody @Validated PageRequest<StaffSceneMerchantReq> req) {
return staffRemote.listSceneMerchantStaff(req);
}
}
  • @wangxw1
    commented
    Master

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

    1. 【安全性与逻辑缺陷】fillOperator 方法存在越权/身份伪造风险(高危)

    • 问题描述:在 CluesController.java 的 fillOperator 方法中,逻辑存在严重漏洞。如果 ThreadLocalCache.getLoginInfo() 返回空,或者缺少信息,代码并不会立即报错,而是继续执行下方的 if (!StringUtils.hasText(req.getOperatorId()) ...) 校验。这意味着,如果恶意用户在请求体(JSON)中主动伪造并传入了 operatorId 和 operatorName,即使没有登录态,也能绕过校验,导致越权操作。
    • 优化建议:必须强制从当前会话获取操作人信息,并覆盖前端传入的值。如果获取不到,应立即抛出异常。 java private void fillOperator(AddCluesFollowRecordReq req) { LoginUserInfoResponse loginInfo = ThreadLocalCache.getLoginInfo(); if (loginInfo == null || !StringUtils.hasText(loginInfo.getUuid()) || !StringUtils.hasText(loginInfo.getName())) { throw new BusinessException("未获取到当前登录操作人信息,请重新登录"); } // 强制使用后端获取的会话信息,防止前端伪造 req.setOperatorId(loginInfo.getUuid()); req.setOperatorName(loginInfo.getName()); }

    2. 【规范与发布管理】生产环境/Master分支禁止使用 SNAPSHOT 版本

    • 问题描述:根据提交记录 Merge branch 'v5.8.5' into 'master' 上线合并 可知,当前代码正准备合并至 master 分支进行生产发布。但在 pom.xml 中,依赖 gsc-vcp-api 的版本号被修改为了 1.1.2-SNAPSHOT。《阿里巴巴 Java 开发手册》明确规定:正式发布的类库必须先去其版本号中的 SNAPSHOT,并升级至 RELEASE 版本。 SNAPSHOT 是快照版本,具有不稳定性,会导致生产环境构建结果不可预期。
    • 优化建议:在合并至 master 或 release 分支前,将 pom.xml 中的版本号修改为正式版(如 1.1.2 或 1.1.2.RELEASE)。

    3. 【可维护性与最佳实践】滥用 @Autowired 字段注入

    • 问题描述:在 CluesController 和 StaffController 中,均使用了 @Autowired 注解直接在私有字段上进行依赖注入(Field Injection)。这种方式不符合 Spring 的最佳实践,会导致类与 Spring 容器强耦合,无法在外部(如单元测试)通过纯 Java 代码实例化对象,且可能掩盖单一职责原则被破坏的问题。
    • 优化建议:推荐使用构造器注入。如果项目中引入了 Lombok,可以直接使用 @RequiredArgsConstructor 注解来简化代码,这完全符合阿里巴巴规范及 Spring 官方推荐。

      @Tag(name = "PAD端-员工管理")
      @RestController
      @RequestMapping("/staff")
      @RequiredArgsConstructor // 使用 Lombok 替代 @Autowired
      public class StaffController {
      
          private final StaffRemote staffRemote; // 声明为 final
      
          // ...
      }
      

    二、评分明细

    审查项 满分 扣分 得分 备注说明
    1. 功能正确性与健壮性 40 -5 35 fillOperator 逻辑判断顺序存在漏洞;接口中 @RopSession 的使用存在不一致(部分接口有,部分没有,建议统一 BFF 层的鉴权策略)。
    2. 安全性与潜在风险 30 -15 15 存在严重的身份伪造(IDOR/越权)风险,未强制以服务端 Session 为准,扣分较重。
    3. 最佳实践与可维护性 20 -5 15 使用了不被推荐的 Field Injection(字段注入);部分重复的非空校验逻辑可利用 Validator 注解在 DTO 层完成。
    4. 性能与资源利用 5 0 5 主要是 Feign 接口透传,无明显的性能瓶颈及资源浪费问题。
    5. 提交信息质量 5 -2 3 Commit Message 描述非常详细且规范,但“上线合并”包含了 SNAPSHOT 版本,流程管理上存在瑕疵。

    总分:73分

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