Commit 57cf3275 by 崔彦峰

feat(clues): 新增线索跟进记录功能

- 创建 AddCluesFollowRecordReq 请求类定义跟进记录字段
- 在 CluesRemote 接口添加新增跟进记录的 Feign 方法
- 在 CluesController 控制器添加跟进记录接口实现
- 扩展 CluesFollowRecordMapper 添加查询最新跟进记录方法
- 扩展 CluesInfoMapper 添加更新线索跟进信息的方法
- 在 CluesInfoService 服务层实现跟进记录业务逻辑
- 集成操作日志记录功能跟踪线索状态变更
- 在 PAD 端控制器添加跟进记录接口并填充操作人信息
1 parent 42466c3f
...@@ -3,10 +3,15 @@ package com.gsc4cloud.gsc.facade.vpcpad.controller.clues; ...@@ -3,10 +3,15 @@ package com.gsc4cloud.gsc.facade.vpcpad.controller.clues;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gsc4cloud.gsc.common.core.util.R; import com.gsc4cloud.gsc.common.core.util.R;
import com.gsc4cloud.gsc.facade.vpcpad.anotation.RopSession; 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.CluesPageResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesDetailResp; import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesDetailResp;
import com.gsc4cloud.gsc.vpc.api.dto.pad.resdto.clues.CluesStatusCountResp; 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.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.dto.pad.resdto.clues.AddCluesResp;
import com.gsc4cloud.gsc.vpc.api.req.pad.clues.CluesPadPageReq; 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.CluesDetailReq;
...@@ -21,6 +26,7 @@ import org.springframework.web.bind.annotation.PostMapping; ...@@ -21,6 +26,7 @@ import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.util.StringUtils;
@Tag(name = "PAD端-二手车线索管理") @Tag(name = "PAD端-二手车线索管理")
@RestController @RestController
...@@ -36,6 +42,26 @@ public class CluesController { ...@@ -36,6 +42,26 @@ public class CluesController {
return cluesRemote.addClues(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端线索详情") @Operation(summary = "PAD端线索详情")
@PostMapping("/detail") @PostMapping("/detail")
public R<CluesDetailResp> detail(@RequestBody @Validated CluesDetailReq req) { public R<CluesDetailResp> detail(@RequestBody @Validated CluesDetailReq req) {
......
  • @wangxw1
    commented
    Master

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

    1. [安全性/功能正确性] 存在越权与操作人伪造风险(最高优先级)

    • 问题描述:在 fillOperator 方法中,如果 ThreadLocalCache.getLoginInfo() 返回空(例如会话失效或拦截器异常),代码会继续校验 req 中是否自带了 operatorId 和 operatorName。这意味着恶意客户端可以通过在请求体(JSON)中主动传入这两个字段来绕过身份校验,从而伪造他人身份提交跟进记录。
    • 优化建议:后端必须绝对信任服务端的会话上下文,绝不能回退使用客户端传入的操作人信息。建议修改逻辑为: java LoginUserInfoResponse loginInfo = ThreadLocalCache.getLoginInfo(); if (loginInfo == null || !StringUtils.hasText(loginInfo.getUuid())) { // 必须直接抛出异常,不能给客户端伪造的机会 throw new AuthException("获取当前登录用户信息失败,请重新登录"); } req.setOperatorId(loginInfo.getUuid()); req.setOperatorName(loginInfo.getName());

    2. [可维护性/最佳实践] 违反 DRY 原则,上下文信息提取过度耦合

    • 问题描述:在 Controller 方法中手动调用 fillOperator(req) 从 ThreadLocal 中提取用户信息并塞入请求对象,这种做法属于横切关注点(Cross-cutting Concerns)的硬编码。随着接口增加,会导致大量重复的样板代码,违反了 DRY(Don't Repeat Yourself)原则。
    • 优化建议:推荐使用 Spring 的 HandlerMethodArgumentResolver 配合自定义注解(如 @CurrentOperator),直接在 Controller 方法签名中注入当前用户信息;或者在 @RopSession 对应的拦截器/AOP中,利用反射或统一的 BaseRequest 接口自动完成操作人信息的填充。

    3. [功能正确性/异常处理] 异常语义不准确

    • 问题描述:当无法获取操作人信息时,抛出了通用的 BusinessException("操作人信息不能为空")。操作人信息丢失本质上属于认证/授权失败(Authentication/Authorization failure),而不是普通的业务逻辑校验不通过。
    • 优化建议:应当抛出专门的认证异常(如 UnauthorizedException 或带有特定错误码的异常),以便全局异常处理器(GlobalExceptionHandler)能够捕获并返回 HTTP 401 状态码或特定的鉴权失败错误码,引导前端跳转登录页,而不是仅仅提示业务错误。

    二、评分明细

    评审项 满分 得分 扣分原因分析
    功能正确性与健壮性 40 32 fillOperator 的 fallback 逻辑存在严重缺陷,未严格把控数据来源的可靠性。
    安全性与潜在风险 30 18 存在明显的身份伪造(Parameter Tampering / Spoofing)漏洞,客户端可篡改操作人ID。
    最佳实践与可维护性 20 15 异常类型使用不当(认证异常混淆为业务异常);业务控制器中混杂了上下文提取的样板代码。
    性能与资源利用 5 5 字符串校验使用了 Spring 提供的 StringUtils.hasText,无明显性能瓶颈。
    提交信息质量 5 5 Commit message 采用了 Angular 规范(feat(clues): ...),结构清晰,详细列出了各层的变更点,质量极高。

    总分:75分

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