Commit ec4e720b by 叶立庆

Merge branch 'v5.8.8' into 'master'

上线合并

See merge request !29
2 parents 963fff92 e5ad702a
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</parent> </parent>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId> <artifactId>rpc-dj-staff-api</artifactId>
<version>5.8.7.5-SNAPSHOT</version> <version>5.8.8-SNAPSHOT</version>
<name>rpc-dj-staff-api</name> <name>rpc-dj-staff-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.dj.staff.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.dj.staff.remote</deploy.scanPackage>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId> <artifactId>rpc-dj-staff-api</artifactId>
<version>5.8.7.5-SNAPSHOT</version> <version>5.8.8-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
......
...@@ -18,7 +18,7 @@ public class RecruitmentSubSceneDTO implements Serializable { ...@@ -18,7 +18,7 @@ public class RecruitmentSubSceneDTO implements Serializable {
@ApiModelProperty(notes = "门店商户号(查询条件)") @ApiModelProperty(notes = "门店商户号(查询条件)")
private Integer merchantId; private Integer merchantId;
@ApiModelProperty(notes = "招聘需求业务类型值(查询条件)") @ApiModelProperty(notes = "招聘需求业务类型值(兼容保留,不再参与场景过滤)")
private Integer businessType; private Integer businessType;
@ApiModelProperty(notes = "场景编码") @ApiModelProperty(notes = "场景编码")
......
...@@ -122,8 +122,8 @@ public interface RecruitmentDemandRemote { ...@@ -122,8 +122,8 @@ public interface RecruitmentDemandRemote {
@ApiResponse("省份HRBP关系列表") @ApiResponse("省份HRBP关系列表")
RpcResponse<List<RecruitmentProvinceHrbpRelation>> listProvinceHrbpRelation(@NotNull RecruitmentProvinceHrbpRelation condition); RpcResponse<List<RecruitmentProvinceHrbpRelation>> listProvinceHrbpRelation(@NotNull RecruitmentProvinceHrbpRelation condition);
@ApiMethod("查询小场景列表") @ApiMethod("查询小场景列表(目标门店全部经营场景)")
@ApiParam(name = "dto", notes = "查询条件,merchantId/businessType", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "dto", notes = "查询条件,merchantId必填", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("小场景列表") @ApiResponse("小场景列表")
RpcResponse<List<RecruitmentSubSceneDTO>> listSubScenes(@NotNull RecruitmentSubSceneDTO dto); RpcResponse<List<RecruitmentSubSceneDTO>> listSubScenes(@NotNull RecruitmentSubSceneDTO dto);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</parent> </parent>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff</artifactId> <artifactId>rpc-dj-staff</artifactId>
<version>5.8.7.5-SNAPSHOT</version> <version>5.8.8-SNAPSHOT</version>
<name>rpc-dj-staff</name> <name>rpc-dj-staff</name>
<packaging>war</packaging> <packaging>war</packaging>
<dependencies> <dependencies>
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId> <artifactId>rpc-dj-staff-api</artifactId>
<version>5.8.7.5-SNAPSHOT</version> <version>5.8.8-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.oreframework.boot</groupId> <groupId>org.oreframework.boot</groupId>
......
package cn.com.glsx.dj.staff.converter;
import cn.com.glsx.dj.smartcarlife.dto.NewMerchantSceneDTO;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentSubSceneDTO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
/**
* 招聘试岗小场景转换器
* @author yangwei_by_claude
* @version 1.0
* @since 2026/11/24 10:00
*/
@Mapper(componentModel = "spring")
public interface RecruitmentSubSceneConvert {
/**
* 门店已上架场景转换为试岗小场景
*
* @param scene 门店已上架场景
* @return cn.com.glsx.dj.staff.dto.recruitment.RecruitmentSubSceneDTO 试岗小场景
* @author yangwei_by_claude
* @since 2026/11/24 10:00
*/
@Mappings({
@Mapping(target = "merchantId", ignore = true),
@Mapping(target = "businessType", ignore = true),
@Mapping(source = "baseSceneCode", target = "sceneCode"),
@Mapping(source = "baseSceneCodeName", target = "sceneName")
})
RecruitmentSubSceneDTO toSubSceneDTO(NewMerchantSceneDTO scene);
}
...@@ -14,6 +14,7 @@ import cn.com.glsx.dj.sale.dto.SalePotentialCustomerBrandDTO; ...@@ -14,6 +14,7 @@ import cn.com.glsx.dj.sale.dto.SalePotentialCustomerBrandDTO;
import cn.com.glsx.dj.sale.dto.SalePotentialCustomersDetailDTO; import cn.com.glsx.dj.sale.dto.SalePotentialCustomersDetailDTO;
import cn.com.glsx.dj.sale.remote.SalePotentialCustomersRemote; import cn.com.glsx.dj.sale.remote.SalePotentialCustomersRemote;
import cn.com.glsx.dj.smartcarlife.remote.*; import cn.com.glsx.dj.smartcarlife.remote.*;
import cn.com.glsx.dj.staff.converter.RecruitmentSubSceneConvert;
import cn.com.glsx.dj.staff.dto.recruitment.*; import cn.com.glsx.dj.staff.dto.recruitment.*;
import cn.com.glsx.dj.staff.enums.FlagEnum; import cn.com.glsx.dj.staff.enums.FlagEnum;
import cn.com.glsx.dj.staff.enums.RecruitmentDemandStatusEnum; import cn.com.glsx.dj.staff.enums.RecruitmentDemandStatusEnum;
...@@ -166,6 +167,9 @@ public class RecruitmentDemandService { ...@@ -166,6 +167,9 @@ public class RecruitmentDemandService {
private SceneMerchantRefRemote sceneMerchantRefRemote; private SceneMerchantRefRemote sceneMerchantRefRemote;
@Autowired @Autowired
private RecruitmentSubSceneConvert recruitmentSubSceneConvert;
@Autowired
private SceneRemote sceneRemote; private SceneRemote sceneRemote;
@Autowired @Autowired
...@@ -2624,14 +2628,16 @@ public class RecruitmentDemandService { ...@@ -2624,14 +2628,16 @@ public class RecruitmentDemandService {
} }
/** /**
* 查询小场景列表 * 查询小场景列表(目标门店的全部经营场景,不再与招聘需求指定的场景取交集)
* *
* @param dto 查询条件(merchantId + businessType) * @param dto 查询条件(merchantId)
* @return 小场景列表 * @return 小场景列表
* @author yangwei_by_claude
* @since 2026/11/24 10:00
*/ */
public List<RecruitmentSubSceneDTO> listSubScenes(RecruitmentSubSceneDTO dto) { public List<RecruitmentSubSceneDTO> listSubScenes(RecruitmentSubSceneDTO dto) {
try { try {
// 1. 通过门店商户号查询门店已上架的全部小场景 // 1. 通过门店商户号查询门店已上架的全部经营场景
RpcResponse<List<NewMerchantSceneDTO>> sceneResp = sceneMerchantRefRemote.findAllSceneByMerchantId(dto.getMerchantId()); RpcResponse<List<NewMerchantSceneDTO>> sceneResp = sceneMerchantRefRemote.findAllSceneByMerchantId(dto.getMerchantId());
if (sceneResp == null || CollectionUtils.isEmpty(sceneResp.getResult())) { if (sceneResp == null || CollectionUtils.isEmpty(sceneResp.getResult())) {
log.info("查询小场景列表-门店无已上架场景,merchantId:{}", dto.getMerchantId()); log.info("查询小场景列表-门店无已上架场景,merchantId:{}", dto.getMerchantId());
...@@ -2640,28 +2646,16 @@ public class RecruitmentDemandService { ...@@ -2640,28 +2646,16 @@ public class RecruitmentDemandService {
List<NewMerchantSceneDTO> merchantSceneList = sceneResp.getResult(); List<NewMerchantSceneDTO> merchantSceneList = sceneResp.getResult();
log.info("查询小场景列表-门店已上架场景数量:{},merchantId:{}", merchantSceneList.size(), dto.getMerchantId()); log.info("查询小场景列表-门店已上架场景数量:{},merchantId:{}", merchantSceneList.size(), dto.getMerchantId());
// 2. 根据业务类型获取允许的场景编号列表 // 2. 直接转换门店全部经营场景(不再按招聘需求业务类型过滤),按场景编码去重
List<String> allowedNums = getAllowedNumsByBusinessType(dto.getBusinessType()); List<RecruitmentSubSceneDTO> result = merchantSceneList.stream()
if (CollectionUtils.isEmpty(allowedNums)) { .filter(scene -> scene != null && StringUtils.isNotBlank(scene.getBaseSceneCode()))
log.info("查询小场景列表-业务类型无对应场景映射,businessType:{}", dto.getBusinessType()); .collect(Collectors.collectingAndThen(
return new ArrayList<>(); Collectors.toMap(NewMerchantSceneDTO::getBaseSceneCode,
} recruitmentSubSceneConvert::toSubSceneDTO,
log.info("查询小场景列表-业务类型:{}, 允许场景编号:{}", dto.getBusinessType(), allowedNums); (scene1, scene2) -> scene1,
LinkedHashMap::new),
// 3. 过滤门店已上架的小场景(匹配场景编号) map -> new ArrayList<>(map.values())));
List<NewMerchantSceneDTO> filteredList = merchantSceneList.stream() log.info("查询小场景列表-返回场景数量:{},merchantId:{}", result.size(), dto.getMerchantId());
.filter(scene -> allowedNums.contains(scene.getNum()))
.collect(Collectors.toList());
log.info("查询小场景列表-过滤后场景数量:{},merchantId:{}", filteredList.size(), dto.getMerchantId());
// 4. 转换小场景数据对象并返回
List<RecruitmentSubSceneDTO> result = new ArrayList<>();
for (NewMerchantSceneDTO scene : filteredList) {
result.add(RecruitmentSubSceneDTO.builder()
.sceneCode(scene.getBaseSceneCode())
.sceneName(scene.getBaseSceneCodeName())
.build());
}
return result; return result;
} catch (Exception e) { } catch (Exception e) {
log.error("查询小场景列表异常,merchantId:{}, businessType:{}", dto.getMerchantId(), dto.getBusinessType(), e); log.error("查询小场景列表异常,merchantId:{}, businessType:{}", dto.getMerchantId(), dto.getBusinessType(), e);
......
...@@ -146,7 +146,7 @@ public class RecruitmentDemandServiceTest extends BaseServiceTest { ...@@ -146,7 +146,7 @@ public class RecruitmentDemandServiceTest extends BaseServiceTest {
@Test @Test
public void testListSubScenes() { public void testListSubScenes() {
RecruitmentSubSceneDTO dto = new RecruitmentSubSceneDTO(); RecruitmentSubSceneDTO dto = new RecruitmentSubSceneDTO();
dto.setMerchantId(44217681); dto.setMerchantId(44211227);
dto.setBusinessType(2); dto.setBusinessType(2);
List<RecruitmentSubSceneDTO> list = recruitmentDemandService.listSubScenes(dto); List<RecruitmentSubSceneDTO> list = recruitmentDemandService.listSubScenes(dto);
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议,如果必要,给出代码示例(仅限 Top 3)

    问题 1:缺少对入参 dto 及核心必填字段 merchantId 的前置空值校验
    • 问题描述: 在 RecruitmentDemandService#listSubScenes(RecruitmentSubSceneDTO dto) 中,直接调用了 dto.getMerchantId() 传给下游 RPC 接口 sceneMerchantRefRemote.findAllSceneByMerchantId(...)。虽然 Remote 接口层标注了 @NotNull RecruitmentSubSceneDTO dto 和注释“merchantId必填”,但 RecruitmentSubSceneDTO 内部的 merchantId 字段未加 @NotNull 校验注解,且 Service 层作为内部核心业务方法未做防御性判空。
    • 影响分析:
      1. 若内部其他 Service 直接调用该方法且传入 null,会直接触发 NullPointerException 并被 catch (Exception e) 吞没,导致异常掩盖;
      2. 若上游传入 dto != null 但 merchantId == null,会发起一次无效的跨服务 Dubbo 远程调用,既浪费网络/线程池资源,又可能引发下游服务报错。
    • 优化建议: 在 RecruitmentSubSceneDTO#merchantId 上补充 JSR-303 参数校验注解(视业务场景而定),同时在 RecruitmentDemandService#listSubScenes 入口处增加显式的防御性判空。
    public List<RecruitmentSubSceneDTO> listSubScenes(RecruitmentSubSceneDTO dto) {
        if (dto == null || dto.getMerchantId() == null) {
            log.warn("查询小场景列表-入参或merchantId为空,dto:{}", dto);
            return new ArrayList<>();
        }
        try {
            RpcResponse<List<NewMerchantSceneDTO>> sceneResp = sceneMerchantRefRemote.findAllSceneByMerchantId(dto.getMerchantId());
            // 建议同时判断下游 RPC 调用状态是否成功
            if (sceneResp == null || !sceneResp.isSuccess() || CollectionUtils.isEmpty(sceneResp.getResult())) {
                log.info("查询小场景列表-门店无已上架场景或调用失败,merchantId:{}", dto.getMerchantId());
                return new ArrayList<>();
            }
            // ... 后续转换与去重逻辑
        } catch (Exception e) {
            log.error("查询小场景列表异常,merchantId:{}", dto.getMerchantId(), e);
            return new ArrayList<>();
        }
    }
    
    问题 2:单元测试仅修改了测试参数,未同步更新业务语义变更后的断言逻辑
    • 问题描述: 本次变更的核心业务改动是“不再根据 businessType 过滤小场景,改为返回门店全部经营场景”,但 RecruitmentDemandServiceTest#testListSubScenes 中仅仅将 merchantId 从 44217681 改为 44211227,仍保留了 dto.setBusinessType(2),且从 diff 上下文看未看到针对“忽略 businessType 返回全量场景”、“按 baseSceneCode 去重”以及“merchantId 为空”等新逻辑的断言覆盖。
    • 影响分析: 弱断言或缺乏针对变更点的单元测试无法有效验证重构后的业务预期,后续迭代若有人误改过滤逻辑,单测无法起到回归防护网的作用。
    • 优化建议: 补充或完善单元测试用例,覆盖以下场景:
      1. 传入不同 businessType(或 businessType = null)时,返回结果一致且为门店全量去重后的场景列表;
      2. 传入 merchantId = null 时的边界行为验证。
    问题 3:存在潜在的废弃代码残留(Dead Code)及对外 API 语义破坏性变更风险
    • 问题描述:
      1. RecruitmentDemandService 中原有的私有方法 getAllowedNumsByBusinessType(...) 在本次重构中已被移除调用,但 diff 中未见将其删除(若已无其他调用方,属于死代码);
      2. 虽然 Dubbo Remote 接口的方法签名与 RecruitmentSubSceneDTO 字段结构保持了向后兼容(未修改参数类型或删除字段),但接口的业务过滤契约发生了实质性改变(原本按 businessType 过滤,现在忽略该条件直接返回全量)。
    • 影响分析:
      1. 残留无用私有方法会增加后续维护者的理解成本;
      2. 若存在其他未知历史调用方依赖 listSubScenes 按 businessType 过滤的结果,升级 API 后会出现返回数据量变多、业务数据越界展示的风险。
    • 优化建议:
      1. 检查 getAllowedNumsByBusinessType 是否在当前类中还有其他引用,若无引用应一并清理;
      2. 确认所有调用 RecruitmentDemandRemote#listSubScenes 的下游消费方均已对齐“返回门店全部经营场景”的业务预期,避免隐性兼容问题。

    二、评分明细

    1. 功能实现的正确性与健壮性(36/40分)
      • 理由:使用 MapStruct 替代手动 Builder 映射、采用 LinkedHashMap 按 baseSceneCode 去重并保持顺序、过滤空元素与空编码等实现清晰准确;Dubbo 接口保留 businessType 字段做到签名兼容,未破坏已有入参结构。扣分点在于 Service 入口缺少对 dto 和 merchantId 的前置判空防御,以及单元测试未充分覆盖新逻辑与边界场景。
    2. 安全性与潜在风险(28/30分)
      • 理由:未涉及 SQL 拼接或子查询问题,无注入与敏感信息泄露风险;接口参数结构保持向后兼容,未违反接口参数变更红线。扣分点在于接口返回范围从“特定业务类型子集”扩大为“门店全量经营场景”,需确保调用方不存在数据越权展示风险,且缺少入参空值拦截。
    3. 最佳实践与可维护性(18/20分)
      • 理由:引入 MapStruct 转换器解耦对象转换逻辑,类名、方法注释、Swagger 文档同步更新及时,代码整洁易读。扣分点在于疑似残留未使用的历史私有方法 getAllowedNumsByBusinessType,以及单测维护不够严谨。
    4. 性能与资源利用(5/5分)
      • 理由:内存流式去重与转换时间复杂度为 $O(N)$,针对单门店场景数量级无性能瓶颈,资源利用合理。
    5. 提交信息质量(5/5分)
      • 理由:遵循 Conventional Commits 规范(refactor(recruitment): ...),变更摘要清晰列出了重构点、兼容性处理及版本号升级,可追溯性强。

    总分:92分

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