Commit b8cd6239 by 叶立庆

Merge branch 'v5.8.6' into 'master'

上线合并

See merge request !9
2 parents fa4e253d 2922c721
Showing 18 changed files with 317 additions and 6 deletions
...@@ -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-riskmanage-api</artifactId> <artifactId>rpc-dj-riskmanage-api</artifactId>
<version>5.8.3.6-SNAPSHOT</version> <version>5.8.6-SNAPSHOT</version>
<name>rpc-dj-riskmanage-api</name> <name>rpc-dj-riskmanage-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.dj.riskmanage.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.dj.riskmanage.remote</deploy.scanPackage>
......
...@@ -46,6 +46,18 @@ public class LevelExamDetailDTO implements java.io.Serializable { ...@@ -46,6 +46,18 @@ public class LevelExamDetailDTO implements java.io.Serializable {
private String positionName; private String positionName;
/** /**
* 品牌ID列表(逗号分隔)
*/
@ApiModelProperty(notes = "品牌ID列表(逗号分隔)")
private String brandIds;
/**
* 品牌名称列表(逗号分隔)
*/
@ApiModelProperty(notes = "品牌名称列表(逗号分隔)")
private String brandNames;
/**
* 考试时间 * 考试时间
*/ */
private Integer examTime; private Integer examTime;
......
...@@ -101,5 +101,10 @@ public class LevelExamDetailResponseDTO implements Serializable { ...@@ -101,5 +101,10 @@ public class LevelExamDetailResponseDTO implements Serializable {
@ApiModelProperty(notes = "生效方式 (1:立即生效, 2:定时生效)") @ApiModelProperty(notes = "生效方式 (1:立即生效, 2:定时生效)")
private Byte effectiveType; private Byte effectiveType;
@ApiModelProperty(notes = "品牌ID列表(逗号分隔)")
private String brandIds;
@ApiModelProperty(notes = "品牌名称列表(逗号分隔)")
private String brandNames;
} }
...@@ -85,6 +85,12 @@ public class LevelExamPageListRequestDTO implements Serializable { ...@@ -85,6 +85,12 @@ public class LevelExamPageListRequestDTO implements Serializable {
private Integer planId; private Integer planId;
/** /**
* 品牌ID筛选
*/
@ApiModelProperty(notes = "品牌ID筛选")
private Integer brandId;
/**
* 状态 (0:草稿, 1:未生效, 2:生效, 3:失效) * 状态 (0:草稿, 1:未生效, 2:生效, 3:失效)
*/ */
@ApiModelProperty(notes = "状态list (0:草稿, 1:未生效, 2:生效, 3:失效)") @ApiModelProperty(notes = "状态list (0:草稿, 1:未生效, 2:生效, 3:失效)")
......
...@@ -59,6 +59,12 @@ public class LevelExamPageListResponseDTO implements Serializable { ...@@ -59,6 +59,12 @@ public class LevelExamPageListResponseDTO implements Serializable {
@ApiModelProperty(notes = "职务名称") @ApiModelProperty(notes = "职务名称")
private String positionName; private String positionName;
@ApiModelProperty(notes = "品牌ID列表(逗号分隔)")
private String brandIds;
@ApiModelProperty(notes = "品牌名称列表(逗号分隔)")
private String brandNames;
/** /**
* 考试时间 * 考试时间
......
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 根据职务查询品牌筛选选项请求
*/
@Data
public class LevelExamPositionBrandRequest implements Serializable {
/**
* 职务编码(北森 OId)
*/
@ApiModelProperty(notes = "职务编码(北森 OId),与职务名称二选一")
private String positionCode;
/**
* 职务名称
*/
@ApiModelProperty(notes = "职务名称,与职务编码二选一")
private String positionName;
}
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 根据职务查询品牌筛选选项响应
*/
@Data
public class LevelExamPositionBrandResponse implements Serializable {
/**
* 品牌ID(一级品牌 firstBrandId)
*/
@ApiModelProperty(notes = "品牌ID")
private Integer brandId;
/**
* 品牌名称
*/
@ApiModelProperty(notes = "品牌名称")
private String brandName;
}
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import lombok.Data;
import java.io.Serializable;
/**
* 招聘需求品牌信息(兜底路径)
*/
@Data
public class RecruitmentBrandDTO implements Serializable {
/**
* 员工手机号
*/
private String phoneNumber;
/**
* 招聘需求品牌文本(如"鸿蒙智行/焜驰/起亚")
*/
private String brand;
}
package cn.com.glsx.dj.riskmanage.dto.learningcenter;
import lombok.Data;
import java.io.Serializable;
/**
* 员工最新上架门店关联信息
*/
@Data
public class StaffLatestMerchantDTO implements Serializable {
/**
* 员工手机号
*/
private String staffPhone;
/**
* 关联的商户ID
*/
private Integer merchantId;
}
...@@ -52,6 +52,18 @@ public class LearningCenterLevelExam { ...@@ -52,6 +52,18 @@ public class LearningCenterLevelExam {
private String positionName; private String positionName;
/** /**
* 品牌ID列表(逗号分隔)
*/
@Column(name = "brand_ids")
private String brandIds;
/**
* 品牌名称列表(逗号分隔)
*/
@Column(name = "brand_names")
private String brandNames;
/**
* 考试时间 * 考试时间
*/ */
@Column(name = "exam_time") @Column(name = "exam_time")
......
...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.riskmanage.remote; ...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.riskmanage.remote;
import cn.com.glsx.dj.riskmanage.dto.beisen.OrganizationListResponseDTO; import cn.com.glsx.dj.riskmanage.dto.beisen.OrganizationListResponseDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.*; import cn.com.glsx.dj.riskmanage.dto.learningcenter.*;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPositionBrandResponse;
import cn.com.glsx.framework.core.annotation.ApiMethod; import cn.com.glsx.framework.core.annotation.ApiMethod;
import cn.com.glsx.framework.core.annotation.ApiParam; import cn.com.glsx.framework.core.annotation.ApiParam;
import cn.com.glsx.framework.core.annotation.ApiResponse; import cn.com.glsx.framework.core.annotation.ApiResponse;
...@@ -50,4 +51,9 @@ public interface LearningCenterLevelExamRemote { ...@@ -50,4 +51,9 @@ public interface LearningCenterLevelExamRemote {
@ApiParam(name = "pagination", notes = "考试人员列表查询", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "pagination", notes = "考试人员列表查询", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("考试人员列表查询") @ApiResponse("考试人员列表查询")
RpcResponse<RpcPagination<LevelExamPersonDTO>> levelExamDataPersonPage(RpcPagination<LevelExamPersonDTO> pagination); RpcResponse<RpcPagination<LevelExamPersonDTO>> levelExamDataPersonPage(RpcPagination<LevelExamPersonDTO> pagination);
@ApiMethod("根据职务查询品牌筛选选项")
@ApiParam(name = "request", notes = "职务编码或职务名称", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("品牌筛选选项")
RpcResponse<List<LevelExamPositionBrandResponse>> queryPositionBrandOptions(@NotNull LevelExamPositionBrandRequest request);
} }
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-riskmanage-api</artifactId> <artifactId>rpc-dj-riskmanage-api</artifactId>
<version>5.8.3.6-SNAPSHOT</version> <version>5.8.6-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.merchants</groupId> <groupId>cn.com.glsx.merchants</groupId>
......
...@@ -2,10 +2,14 @@ package cn.com.glsx.dj.riskmanage.mapper.learningcenter; ...@@ -2,10 +2,14 @@ package cn.com.glsx.dj.riskmanage.mapper.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LearningCenterLevelExamPersonDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LearningCenterLevelExamPersonDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPersonDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPersonDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.RecruitmentBrandDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.StaffLatestMerchantDTO;
import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExamPerson; import cn.com.glsx.dj.riskmanage.model.learningcenter.LearningCenterLevelExamPerson;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper; import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.Collection;
import java.util.List; import java.util.List;
@Mapper @Mapper
...@@ -24,4 +28,18 @@ public interface LearningCenterLevelExamPersonMapper extends OreMapper<LearningC ...@@ -24,4 +28,18 @@ public interface LearningCenterLevelExamPersonMapper extends OreMapper<LearningC
List<LearningCenterLevelExamPersonDTO> findLevelExamPerson(Integer userId); List<LearningCenterLevelExamPersonDTO> findLevelExamPerson(Integer userId);
List<LearningCenterLevelExamPersonDTO> findLevelExamPersonWithEffective(Integer userId); List<LearningCenterLevelExamPersonDTO> findLevelExamPersonWithEffective(Integer userId);
/**
* 批量查询员工最新上架记录关联的商户ID(按手机号去重取MAX(id))
* @param phones 手机号列表
* @return StaffLatestMerchantDTO 列表
*/
List<StaffLatestMerchantDTO> selectLatestMerchantIdByPhones(@Param("phones") Collection<String> phones);
/**
* 批量查询招聘需求品牌名称(兜底路径,无上架门店记录时使用)
* @param phones 手机号列表
* @return RecruitmentBrandDTO 列表
*/
List<RecruitmentBrandDTO> selectRecruitmentBrandNamesByPhones(@Param("phones") Collection<String> phones);
} }
\ No newline at end of file \ No newline at end of file
...@@ -128,4 +128,17 @@ public class LearningCenterLevelExamRemoteImpl implements LearningCenterLevelExa ...@@ -128,4 +128,17 @@ public class LearningCenterLevelExamRemoteImpl implements LearningCenterLevelExa
return RpcResponse.error(e); return RpcResponse.error(e);
} }
} }
@Override
public RpcResponse<List<LevelExamPositionBrandResponse>> queryPositionBrandOptions(LevelExamPositionBrandRequest request) {
try {
return RpcResponse.success(learningCenterLevelExamService.queryPositionBrandOptions(request));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
} }
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
<result column="department_name" property="departmentName" jdbcType="VARCHAR" /> <result column="department_name" property="departmentName" jdbcType="VARCHAR" />
<result column="position_code" property="positionCode" jdbcType="VARCHAR" /> <result column="position_code" property="positionCode" jdbcType="VARCHAR" />
<result column="position_name" property="positionName" jdbcType="VARCHAR" /> <result column="position_name" property="positionName" jdbcType="VARCHAR" />
<result column="brand_ids" property="brandIds" jdbcType="VARCHAR" />
<result column="brand_names" property="brandNames" jdbcType="VARCHAR" />
<result column="exam_time" property="examTime" jdbcType="INTEGER" /> <result column="exam_time" property="examTime" jdbcType="INTEGER" />
<result column="learning_center_permission" property="learningCenterPermission" jdbcType="TINYINT" /> <result column="learning_center_permission" property="learningCenterPermission" jdbcType="TINYINT" />
<result column="effective_type" property="effectiveType" jdbcType="TINYINT" /> <result column="effective_type" property="effectiveType" jdbcType="TINYINT" />
...@@ -32,8 +34,8 @@ ...@@ -32,8 +34,8 @@
<!-- <!--
WARNING - @mbg.generated WARNING - @mbg.generated
--> -->
id, beisen_exam_id, beisen_exam_name, department_id, department_name, position_code, position_name, exam_time, id, beisen_exam_id, beisen_exam_name, department_id, department_name, position_code, position_name, brand_ids, brand_names,
learning_center_permission, effective_type, effective_time, status, submitted_count, creator, exam_time, learning_center_permission, effective_type, effective_time, status, submitted_count, creator,
created_by, created_date, updated_by, updated_date, deleted_flag created_by, created_date, updated_by, updated_date, deleted_flag
</sql> </sql>
<update id="completionIncreaseCount"> <update id="completionIncreaseCount">
...@@ -103,10 +105,13 @@ ...@@ -103,10 +105,13 @@
</if> </if>
<if test="statusList != null and statusList.size() > 0"> <if test="statusList != null and statusList.size() > 0">
AND exam.status in AND exam.status in
<foreach item="item" collection="statusList" separator="," open="(" close=")" index=""> <foreach item="item" collection="statusList" separator="," open="(" close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="brandId != null">
AND FIND_IN_SET(#{brandId}, exam.brand_ids) > 0
</if>
ORDER BY ORDER BY
<choose> <choose>
<when test="orderByType != null and orderByType == 0"> <when test="orderByType != null and orderByType == 0">
......
...@@ -127,4 +127,42 @@ ...@@ -127,4 +127,42 @@
AND t3.deleted_flag = 'N' AND t3.deleted_flag = 'N'
AND t3.status = '2' AND t3.status = '2'
</select> </select>
<resultMap id="StaffLatestMerchantResult" type="cn.com.glsx.dj.riskmanage.dto.learningcenter.StaffLatestMerchantDTO">
<result column="staff_phone" property="staffPhone" jdbcType="VARCHAR" />
<result column="merchant_id" property="merchantId" jdbcType="INTEGER" />
</resultMap>
<resultMap id="RecruitmentBrandResult" type="cn.com.glsx.dj.riskmanage.dto.learningcenter.RecruitmentBrandDTO">
<result column="phone_number" property="phoneNumber" jdbcType="VARCHAR" />
<result column="brand" property="brand" jdbcType="VARCHAR" />
</resultMap>
<select id="selectLatestMerchantIdByPhones" resultMap="StaffLatestMerchantResult">
SELECT sar.staff_phone, sar.merchant_id
FROM dj_smartcarlife.dj_car_life_staff_account_assign_record sar
INNER JOIN (
SELECT staff_phone, MAX(id) AS max_id
FROM dj_smartcarlife.dj_car_life_staff_account_assign_record
WHERE staff_phone IN
<foreach item="item" index="index" collection="phones" separator="," open="(" close=")">
#{item}
</foreach>
AND deleted_flag = 'N'
AND merchant_id IS NOT NULL
GROUP BY staff_phone
) latest ON sar.staff_phone = latest.staff_phone AND sar.id = latest.max_id
</select>
<select id="selectRecruitmentBrandNamesByPhones" resultMap="RecruitmentBrandResult">
SELECT plan.phone_number, d.brand
FROM dj_smartcarlife.dj_car_life_recruitment_onboarding_plan plan
INNER JOIN dj_smartcarlife.dj_car_life_recruitment_demand d ON plan.demand_id = d.id
WHERE plan.phone_number IN
<foreach item="item" index="index" collection="phones" separator="," open="(" close=")">
#{item}
</foreach>
AND plan.deleted_flag = 'N'
AND d.deleted_flag = 'N'
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,8 @@ package cn.com.glsx.dj.riskmanage.service.learningcenter; ...@@ -2,6 +2,8 @@ package cn.com.glsx.dj.riskmanage.service.learningcenter;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamDetailDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamDetailDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamLevelDTO; import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamLevelDTO;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPositionBrandRequest;
import cn.com.glsx.dj.riskmanage.dto.learningcenter.LevelExamPositionBrandResponse;
import cn.com.glsx.dj.riskmanage.service.BaseServiceTest; import cn.com.glsx.dj.riskmanage.service.BaseServiceTest;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import org.junit.Test; import org.junit.Test;
...@@ -130,6 +132,99 @@ public class LearningCenterLevelExamServiceTest extends BaseServiceTest { ...@@ -130,6 +132,99 @@ public class LearningCenterLevelExamServiceTest extends BaseServiceTest {
@Test @Test
public void testPushExamToEmployees() { public void testPushExamToEmployees() {
levelExamService.pushExamToEmployees(11); levelExamService.pushExamToEmployees(13);
}
/**
* 品牌岗位创建带品牌考试
*/
@Test
public void testAddLevelExam_BrandPosition() {
LevelExamDetailDTO request = new LevelExamDetailDTO();
String creator = "xiehx";
request.setCreator(creator);
request.setCreatedBy(creator);
request.setUpdatedBy(creator);
request.setBeisenExamId("e77c8fa1-ad30-4803-967a-231f22090f48");
request.setPositionCode("862166");
request.setPositionName("延保门店销售");
request.setExamTime(30);
request.setBrandIds("1,2");
request.setBrandNames("问界,鸿蒙");
request.setLearningCenterPermission((byte) 1);
request.setEffectiveType((byte) 1);
request.setStatus((byte) 1);
List<LevelExamLevelDTO> levels = new ArrayList<>();
LevelExamLevelDTO level1 = new LevelExamLevelDTO();
level1.setLevelName("B级");
level1.setMinScore(0);
level1.setMaxScore(60);
level1.setSortOrder(1);
levels.add(level1);
LevelExamLevelDTO level2 = new LevelExamLevelDTO();
level2.setLevelName("A级");
level2.setMinScore(61);
level2.setMaxScore(100);
level2.setSortOrder(2);
levels.add(level2);
request.setLevelExamLevels(levels);
Integer examId = levelExamService.addLevelExam(request);
System.out.println("品牌岗位创建考试完成 examId=" + examId);
}
/**
* 品牌岗位切换到非品牌岗位,验证品牌字段被清空
*/
@Test
public void testUpdateLevelExam_SwitchToNonBrand() {
LevelExamDetailDTO request = new LevelExamDetailDTO();
request.setId(25);
request.setStatus((byte) 1);
String creator = "xiehx";
request.setUpdatedBy(creator);
request.setBeisenExamId("e77c8fa1-ad30-4803-967a-231f22090f48");
request.setDepartmentId(900433700);
request.setPositionCode("862110");
request.setPositionName("销售顾问");
request.setExamTime(30);
request.setBrandIds("3,4");
request.setBrandNames("起亚,现代");
request.setLearningCenterPermission((byte) 1);
request.setEffectiveType((byte) 1);
levelExamService.updateLevelExam(request);
System.out.println("品牌岗位切换到非品牌岗位完成");
}
/**
* queryPositionBrandOptions 匹配成功场景
* 需确保 env.level.exam.brand.positions 包含"延保门店销售"
*/
@Test
public void testQueryPositionBrandOptions_Matched() {
LevelExamPositionBrandRequest req = new LevelExamPositionBrandRequest();
req.setPositionCode("862166");
req.setPositionName("延保门店销售");
List<LevelExamPositionBrandResponse> res = levelExamService.queryPositionBrandOptions(req);
System.out.println("匹配成功品牌数量=" + (res != null ? res.size() : 0));
}
/**
* queryPositionBrandOptions 匹配失败场景
* 职务名称不在 env.level.exam.brand.positions 配置中
*/
@Test
public void testQueryPositionBrandOptions_Unmatched() {
LevelExamPositionBrandRequest req = new LevelExamPositionBrandRequest();
req.setPositionCode("862110");
req.setPositionName("销售顾问");
List<LevelExamPositionBrandResponse> res = levelExamService.queryPositionBrandOptions(req);
System.out.println("匹配失败品牌数量=" + (res != null ? res.size() : 0));
} }
} }
  • @wangxw1
    commented
    Master

    这是一份针对您提交代码的专业审查报告。审查重点围绕功能健壮性、分布式系统稳定性以及潜在的运行时异常。

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

    1. 严重:updateLevelExam 方法中存在明确的 NullPointerException 风险

    • 问题描述:在 LearningCenterLevelExamService.java 的 updateLevelExam 方法中,获取新职务信息时逻辑存在缺陷。若 getBeiSenJobPost(newPositionCode) 返回 null,代码在 if 块中重复调用了一次相同的获取方法(依然会是 null),随后直接调用了 newJobPost.getName(),这将必然触发空指针异常。
    • 影响分析:当外部系统(北森)中该职务编码失效或不存在时,更新等级考试的操作将直接崩溃,导致接口抛出 500 异常,阻断业务流程。
    • 优化建议:增加对 newJobPost 的空值校验,若不存在应抛出明确的业务异常。 ```java // 修改前 if (newJobPost == null) { newJobPost = getBeiSenJobPost(newPositionCode); } oldLevelExam.setPositionName(newJobPost.getName());

    // 修改后 if (newJobPost == null) { throw new RpcServiceException(DefaultErrorEnum.BUSINESS_ERROR, "无法获取对应职务信息,请核对职务编码"); } oldLevelExam.setPositionName(newJobPost.getName());

    
    **2. 严重:`splitBrandText` 方法未处理入参为空的情况,存在 NPE 风险**
    - **问题描述**:在兜底逻辑 `buildFallbackPathBrandMap` 中,遍历从数据库查询出的 `RecruitmentBrandDTO` 时,直接将 `row.getBrand()` 传入 `splitBrandText` 方法。该方法内部直接调用了 `brandText.split("/")`。
    - **影响分析**:如果数据库中某条招聘需求的 `brand` 字段为 `NULL`,`splitBrandText` 将抛出 `NullPointerException`。这会导致整个品牌过滤逻辑中断,进而导致该场考试的人员推送全部失败。
    - **优化建议**:在 `splitBrandText` 方法首行增加对入参的判空处理。
      ```java
      private Set<String> splitBrandText(String brandText) {
          if (StringUtils.isBlank(brandText)) {
              return Collections.emptySet();
          }
          return Arrays.stream(brandText.split("/"))
                  .map(String::trim)
                  .filter(s -> !s.isEmpty())
                  .collect(Collectors.toSet());
      }
    

    3. 警告:RPC 批量查询未做分片处理,存在超限与超时风险

    • 问题描述:在 buildMainPathBrandMap 中,直接将全量的 merchantIds 转换为 ArrayList 后调用 RPC 接口 merchantRemote.getBrandByMerchantIds(...)。
    • 影响分析:如果参与等级考试的员工基数较大,merchantIds 集合可能包含数千个 ID。将如此巨大的集合一次性通过 Dubbo 传输,极易触发 Dubbo 的 Payload 长度限制(默认 8MB),同时也极易导致服务提供方底层的 SQL 出现 IN 子句超限(如 MySQL 对 IN 数量的性能瓶颈)或执行超时。
    • 优化建议:对 merchantIds 进行分批次(如每批 500 个)调用并合并结果。 java // 优化示例 (借助 Guava 或 Hutool 的分片工具) List<Integer> allMerchantIds = new ArrayList<>(merchantIds); List<List<Integer>> partitions = ListUtil.partition(allMerchantIds, 500); for (List<Integer> batch : partitions) { RpcResponse<List<MerchantBrandDTO>> batchResp = merchantRemote.getBrandByMerchantIds(batch); // ... 处理并合并 batchResp 的结果 }

    二、评分明细

    • 1. 功能实现的正确性与健壮性(28 / 40分)
      • 理由:核心的品牌过滤逻辑(主路径与兜底路径)设计思路清晰。但关键路径上遗留了明显的 NullPointerException 风险(如上述问题 1 和问题 2),且字符串 ID 排序 Arrays.sort(brandIds.split(",")) 采用的是字典序而非数字大小排序(如 "10" 会排在 "2" 前面),虽不影响当前等值比对,但属于逻辑瑕疵。未见违反 Dubbo 参数修改规则。(注:因未提供 Mapper XML 文件,无法实质性审查是否包含 MyBatis 子查询,此处默认符合规范)。
    • 2. 安全性与潜在风险(28 / 30分)
      • 理由:未发现明显的 SQL 注入、越权或敏感信息泄露等安全漏洞。代码结构对外部输入有基本的常规处理。
    • 3. 最佳实践与可维护性(16 / 20分)
      • 理由:代码注释详尽,方法拆分合理,尤其是 filterEmployeesByBrand 的流程控制具有较好的可读性。但在异常处理上,存在直接吞掉异常的情况(如 formatBrandIdsForRepeatCheck 中直接 catch (Exception e) 返回原值),不利于问题排查。
    • 4. 性能与资源利用(3 / 5分)
      • 理由:意识到了使用批量接口替代 for 循环单次调用以解决 N+1 问题,值得表扬。但遗漏了分布式环境下对大批量数据传输的分片控制(问题 3)。
    • 5. 提交信息质量(5 / 5分)
      • 理由:Commit 历史非常规范(遵循了 Angular 规范的 feat/fix 前缀),详细描述了新增功能、修改逻辑及影响范围,具有极高的可追溯性。

    总分:80分

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