Commit 4a755445 by 黄炜

feat: 事项新增招聘需求去除业务限制

1 parent b9ed9690
...@@ -365,12 +365,13 @@ public class TaskInfoService { ...@@ -365,12 +365,13 @@ public class TaskInfoService {
} }
RecruitmentDemand demand = getValidRecruitmentDemand( RecruitmentDemand demand = getValidRecruitmentDemand(
dto.getRecruitmentDemandId(), taskInfo); dto.getRecruitmentDemandId(), taskInfo, executionResult);
return taskStaffReplaceResultConvert.toRecruitmentResult(demand); return taskStaffReplaceResultConvert.toRecruitmentResult(demand);
} }
private RecruitmentDemand getValidRecruitmentDemand( private RecruitmentDemand getValidRecruitmentDemand(
String demandId, TaskInfoDTO taskInfo) { String demandId, TaskInfoDTO taskInfo,
StaffReplaceExecutionResultEnum executionResult) {
RecruitmentDemand demand = getRecruitmentDemand(demandId); RecruitmentDemand demand = getRecruitmentDemand(demandId);
if (demand == null || !NOT_DELETED.equals(demand.getDeletedFlag())) { if (demand == null || !NOT_DELETED.equals(demand.getDeletedFlag())) {
throw new RpcServiceException("招聘需求不存在或已删除"); throw new RpcServiceException("招聘需求不存在或已删除");
...@@ -382,10 +383,12 @@ public class TaskInfoService { ...@@ -382,10 +383,12 @@ public class TaskInfoService {
throw new RpcServiceException("招聘需求不属于当前任务执行人"); throw new RpcServiceException("招聘需求不属于当前任务执行人");
} }
String expectedBusinessType = getRecruitmentBusinessType(taskInfo.getBusinessType()); if (StaffReplaceExecutionResultEnum.LINK_EXISTING_RECRUITMENT_DEMAND.equals(executionResult)) {
if (expectedBusinessType == null String expectedBusinessType = getRecruitmentBusinessType(taskInfo.getBusinessType());
|| !StringUtils.equals(expectedBusinessType, demand.getBusinessType())) { if (expectedBusinessType == null
throw new RpcServiceException("招聘需求业务类型与当前任务不一致"); || !StringUtils.equals(expectedBusinessType, demand.getBusinessType())) {
throw new RpcServiceException("招聘需求业务类型与当前任务不一致");
}
} }
return demand; return demand;
} }
......
  • @wangxw1
    commented
    Master

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

    1. 最佳实践:基础校验方法与特定业务场景强耦合

    • 问题描述:getValidRecruitmentDemand 作为一个通用的内部获取与校验方法,在本次修改中直接硬编码了特定的枚举值(StaffReplaceExecutionResultEnum.LINK_EXISTING_RECRUITMENT_DEMAND)来进行判断。
    • 影响分析:这破坏了方法的通用性与单一职责原则。如果未来新增其他需要跳过或执行此校验的场景,会导致该方法不断堆砌 if-else,违反开闭原则,降低代码的可维护性。
    • 优化建议:建议将特定业务场景的判断解耦。推荐将“是否需要校验业务类型”作为一个 boolean 参数传入,或者直接将业务类型一致性的校验逻辑上移到调用方。
    • 代码示例:

      // 优化方案:传递明确的校验开关,而非具体业务枚举
      private RecruitmentDemand getValidRecruitmentDemand(
            String demandId, TaskInfoDTO taskInfo, boolean requireBusinessTypeCheck) {
        RecruitmentDemand demand = getRecruitmentDemand(demandId);
        // ... 基础校验保持不变 ...
      
        if (requireBusinessTypeCheck) {
            String expectedBusinessType = getRecruitmentBusinessType(taskInfo.getBusinessType());
            if (expectedBusinessType == null
                    || !StringUtils.equals(expectedBusinessType, demand.getBusinessType())) {
                throw new RpcServiceException("招聘需求业务类型与当前任务不一致");
            }
        }
        return demand;
      }
      

    // 调用方: boolean requireCheck = StaffReplaceExecutionResultEnum.LINK_EXISTING_RECRUITMENT_DEMAND.equals(executionResult); RecruitmentDemand demand = getValidRecruitmentDemand(dto.getRecruitmentDemandId(), taskInfo, requireCheck);

    
    *(注:本次代码整体质量较好,除了上述耦合问题外,无其他严重功能、安全或性能缺陷,故仅列出 1 项重要建议。)*
    
    ---
    
    #### 二、评分明细
    
    - **功能实现的正确性与健壮性(40/40分)**:逻辑修改正确,符合“事项新增招聘需求去除业务限制”的预期。在判断枚举相等时,规范地将枚举常量放在前面(`.equals(executionResult)`),有效避免了潜在的空指针异常(NPE)。
    - **安全性与潜在风险(30/30分)**:代码中未引入 SQL 注入、越权等安全风险;变更的方法为 `private`,不属于 Dubbo Remote 接口的参数变更,无兼容性风险。
    - **最佳实践与可维护性(17/20分)**:在底层私有方法中直接依赖了特定的上层业务枚举,导致方法职责不够纯粹,有一定的耦合度,略微影响可维护性和扩展性(扣 3 分)。
    - **性能与资源利用(5/5分)**:判断逻辑清晰,无不必要的资源浪费或性能瓶颈。
    - **提交信息质量(4/5分)**:Commit 信息(`feat: 事项新增招聘需求去除业务限制`)清晰地说明了修改目的,格式规范,但若能简要补充一行实现方式或关联的 Jira/Tapd 任务号,可追溯性会更佳(扣 1 分)。
    
    总分:96分
    
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!