Commit 7077fecd by 王璐琦

feat(permission): 新增飞行督导场景数据权限支持

- 将飞行督导数据权限查询改为基于ShopMerchantDirectorConfigDTO实现
- 区分1.1和2.1两种飞行督导场景权限,分别设置不同权限列表
- SmartCarLife模块新增飞行督导字段及相关接口支持
- 枚举OperationTypeEnum增加飞行督导类型
- RPC接口和DTO新增飞行督导相关字段,支持权限及数据回显
- 修改SQL映射文件,新增飞行督导相关字段查询
- StaffDailyReportHuaweiService中飞行督导负责人过滤条件调整为2.1场景
- 升级相关依赖版本以适应接口变更和功能改进
1 parent a360b451
......@@ -30,6 +30,9 @@ public class ShopMerchantBusinessTypeDTO implements Serializable {
@ApiModelProperty(notes = "线上运营列表")
private List<ShopMerchantDirectorConfig> onlineSupervisionList;
@ApiModelProperty(notes = "飞行督导列表")
private List<ShopMerchantDirectorConfig> flightSupervisionList;
@ApiModelProperty(notes = "运营模式(0:非直营,1:直营)")
private Byte directSalesFlag;
......
......@@ -113,6 +113,9 @@ public class ShopSettingPageDTO implements Serializable {
@ApiModelProperty(notes = "线上运营")
private String onlineSupervision;
@ApiModelProperty(notes = "飞行督导")
private String flightSupervision;
@ApiModelProperty(notes = "业务类型(0:轻改,1:权益,2:延保)")
private Byte businessSceneType;
......
......@@ -8,7 +8,8 @@ package cn.com.glsx.dj.smartcarlife.enums;
public enum OperationTypeEnum {
AREA_SUPERVISION((byte)1,"区域运营"),
ONLINE_SUPERVISION((byte)2,"线上运营");
ONLINE_SUPERVISION((byte)2,"线上运营"),
FLIGHT_SUPERVISION((byte)3,"飞行督导");
private byte value;
private String displayName;
......
......@@ -31,11 +31,11 @@ public class ShopMerchantDirectorConfig implements Serializable{
@ApiModelProperty(notes = "商户号")
@Column(name = "merchant_id")
private Integer merchantId;
/**
* 负责人类型(1:精品升级业务负责人,2:精品升级业务服务商负责人,3:会员权益业务负责人,4:会员权益业务服务商负责人,5:1.1线上运营(原盯防负责人),6:飞行督导,7:2.1线上运营,8:1.1区域运营,9:2.1区域运营)
* 负责人类型(1:精品升级业务负责人,2:精品升级业务服务商负责人,3:会员权益业务负责人,4:会员权益业务服务商负责人,5:1.1线上运营(原盯防负责人),
* 6:1.1飞行督导,7:2.1线上运营,8:1.1区域运营,9:2.1区域运营,10:1.1业务归属,11:2.1业务归属,12:技师督导,13:2.1飞行督导)
*/
@ApiModelProperty(notes = "负责人类型(1:精品升级业务负责人,2:精品升级业务服务商负责人,3:会员权益业务负责人,4:会员权益业务服务商负责人,5:1.1线上运营(原盯防负责人),6:飞行督导,7:2.1线上运营,8:1.1区域运营,9:2.1区域运营,10:1.1业务归属,11:2.1业务归属)")
@ApiModelProperty(notes = "负责人类型(1:精品升级业务负责人,2:精品升级业务服务商负责人,3:会员权益业务负责人,4:会员权益业务服务商负责人,5:1.1线上运营(原盯防负责人),6:1.1飞行督导,7:2.1线上运营,8:1.1区域运营,9:2.1区域运营,10:1.1业务归属,11:2.1业务归属,12:技师督导,13:2.1飞行督导)")
@Column(name = "director_type")
private Byte directorType;
......
......@@ -987,6 +987,17 @@ public class ServiceMerchantService {
}
isHaveCondition = Boolean.TRUE;
}
//飞行督导
if(StringUtils.isNotBlank(condition.getFlightSupervision())){
List<Byte> directorTypes = Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue(), DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue());
ShopMerchantDirectorConfigDTO shopMerchantDirectorConfigDTO = ShopMerchantDirectorConfigDTO.builder()
.deletedFlag(DeletedFlagEnum.N.name()).directorName(condition.getFlightSupervision()).directorTypes(directorTypes).build();
List<Integer> flightMerchantIdList = shopMerchantDirectorConfigService.listMerchantIdByUserName(shopMerchantDirectorConfigDTO);
if(CollectionUtils.isNotEmpty(flightMerchantIdList)){
combinedList.add(flightMerchantIdList);
}
isHaveCondition = Boolean.TRUE;
}
//运营模式
if(ObjectUtil.isNotNull(condition.getDirectSalesFlag())){
Integer djServiceMerchantId = OrePropertyConfigurer.getProperty("dj.specific.partner.merchant.id",Integer.class,44206988);
......@@ -1138,6 +1149,11 @@ public class ServiceMerchantService {
List<ShopMerchantDirectorConfig> onlineSupervisionList = shopMerchantDirectorConfigs.stream()
.filter(shopConfig -> Objects.equals(shopConfig.getDirectorType(), DirectorTypeEnum.DF_DIRECTOR.getValue())).collect(Collectors.toList());
shopMerchantBusinessTypeDTO.setOnlineSupervisionList(onlineSupervisionList);
//飞行督导(6:1.1飞行督导,13:2.1飞行督导)
List<ShopMerchantDirectorConfig> flightSupervisionList = shopMerchantDirectorConfigs.stream()
.filter(shopConfig -> Objects.equals(shopConfig.getDirectorType(), DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).collect(Collectors.toList());
shopMerchantBusinessTypeDTO.setFlightSupervisionList(flightSupervisionList);
}else {
List<ShopMerchantDirectorConfig> areaSupervisionList = shopMerchantDirectorConfigs.stream()
.filter(shopConfig -> Objects.equals(shopConfig.getDirectorType(), DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue())).collect(Collectors.toList());
......@@ -1146,6 +1162,10 @@ public class ServiceMerchantService {
List<ShopMerchantDirectorConfig> onlineSupervisionList = shopMerchantDirectorConfigs.stream()
.filter(shopConfig -> Objects.equals(shopConfig.getDirectorType(), DirectorTypeEnum.DF_DIRECTOR_2_1.getValue())).collect(Collectors.toList());
shopMerchantBusinessTypeDTO.setOnlineSupervisionList(onlineSupervisionList);
List<ShopMerchantDirectorConfig> flightSupervisionList = shopMerchantDirectorConfigs.stream()
.filter(shopConfig -> Objects.equals(shopConfig.getDirectorType(), DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).collect(Collectors.toList());
shopMerchantBusinessTypeDTO.setFlightSupervisionList(flightSupervisionList);
}
}
......@@ -1807,6 +1827,12 @@ public class ServiceMerchantService {
}else {
directorType = DirectorTypeEnum.DF_DIRECTOR.getValue();
}
} else if (Objects.equals(shopMerchantDirectorConfigDTO.getOperationType(),OperationTypeEnum.FLIGHT_SUPERVISION.getValue())) {
if(Objects.equals(shopMerchantDirectorConfigDTO.getSceneType(),SceneTypeEnum.SCENE1_0.getValue())){
directorType = DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue();
}else {
directorType = DirectorTypeEnum.FLIGHT_SUPERVISION.getValue();
}
}
}
return directorType;
......
......@@ -268,7 +268,7 @@ public class StaffDailyReportHuaweiService {
merchantDailyReport.setOnlineSupervision(onlineSupervision);
//飞行督导
String flightSupervision = shopMerchantDirectorConfigs.stream()
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
merchantDailyReport.setFlightSupervision(flightSupervision);
}
//设置品牌
......@@ -2021,7 +2021,7 @@ public class StaffDailyReportHuaweiService {
tempMerchantDailyReport.setOnlineSupervision(onlineSupervision);
//飞行督导
String flightSupervision = shopMerchantDirectorConfigs.stream()
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
tempMerchantDailyReport.setFlightSupervision(flightSupervision);
}
//品牌
......@@ -2420,7 +2420,7 @@ public class StaffDailyReportHuaweiService {
tempMerchantDailyReport.setOnlineSupervision(onlineSupervision);
//飞行督导
String flightSupervision = shopMerchantDirectorConfigs.stream()
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
tempMerchantDailyReport.setFlightSupervision(flightSupervision);
}
......@@ -4725,7 +4725,7 @@ public class StaffDailyReportHuaweiService {
notFilledMerchantReport.setOnlineSupervision(onlineSupervision);
//飞行督导
String flightSupervision = shopMerchantDirectorConfigs.stream()
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
notFilledMerchantReport.setFlightSupervision(flightSupervision);
}
//设置品牌
......@@ -5096,7 +5096,7 @@ public class StaffDailyReportHuaweiService {
tempMerchantDailyReport.setOnlineSupervision(onlineSupervision);
//飞行督导
String flightSupervision = shopMerchantDirectorConfigs.stream()
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
tempMerchantDailyReport.setFlightSupervision(flightSupervision);
}
//品牌
......@@ -5323,7 +5323,7 @@ public class StaffDailyReportHuaweiService {
tempMerchantDailyReport.setOnlineSupervision(onlineSupervision);
//飞行督导
String flightSupervision = shopMerchantDirectorConfigs.stream()
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
.filter(config -> Objects.equals(config.getDirectorType(),DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue())).map(ShopMerchantDirectorConfig::getDirectorName).distinct().collect(Collectors.joining("/"));
tempMerchantDailyReport.setFlightSupervision(flightSupervision);
}
......
  • @wangxw1
    commented
    Master

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

    1. 逻辑错误:场景类型(SceneType)与督导类型映射可能写反(功能正确性)

    • 问题描述:在 ServiceMerchantService.java(约 1827 行)中,当业务类型为飞行督导时,代码判断如果是 SCENE1_0 场景,则返回 FLIGHT_SUPERVISION_2_1(2.1飞行督导);否则返回 FLIGHT_SUPERVISION(1.1飞行督导)。这与常规命名逻辑及上下文(如 1149 行附近的逻辑)完全相反。
    • 影响分析:会导致在查询或分配数据权限时,1.1 场景使用了 2.1 的权限标识,2.1 场景使用了 1.1 的权限标识,引发严重的数据越权或查不到数据的功能 Bug。
    • 优化建议:修正映射逻辑,确保场景版本与枚举定义匹配。 java if(Objects.equals(shopMerchantDirectorConfigDTO.getSceneType(),SceneTypeEnum.SCENE1_0.getValue())){ // 修正为 1.1 场景 directorType = DirectorTypeEnum.FLIGHT_SUPERVISION.getValue(); } else { // 修正为 2.1 场景 directorType = DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue(); }

    2. 逻辑漏洞:条件查询结果为空时未正确处理,导致过滤失效(功能正确性)

    • 问题描述:在 ServiceMerchantService.java(约 987 行)的飞行督导条件过滤中,如果 flightMerchantIdList 为空(即该督导名下没有商户),代码跳过了 combinedList.add(),但依然设置了 isHaveCondition = Boolean.TRUE。
    • 影响分析:在多条件组合查询(通常取交集)的场景下,如果某条件查询结果为空,跳过塞入 combinedList 会导致该过滤条件被实质性丢弃。极端情况下(只有这一个条件且查不到商户),可能触发全量查询,导致数据泄露(用户本不该看到任何数据,却看到了全部数据)。
    • 优化建议:如果根据条件查出的 ID 集合为空,应当向 combinedList 中加入一个空集合或无效 ID(如 -1),或者直接阻断后续查询返回空分页。 java List<Integer> flightMerchantIdList = shopMerchantDirectorConfigService.listMerchantIdByUserName(shopMerchantDirectorConfigDTO); if(CollectionUtils.isNotEmpty(flightMerchantIdList)){ combinedList.add(flightMerchantIdList); } else { // 必须加入空集合或无效占位符,确保交集结果为空 combinedList.add(Collections.singletonList(-1)); } isHaveCondition = Boolean.TRUE;

    3. 危险实现:Dubbo API 模块 DTO 字段变更风险(安全性与稳定性)

    • 问题描述:在 rpc-dj-smartcarlife-api 模块的 ShopMerchantBusinessTypeDTO 和 ShopSettingPageDTO 中新增了 flightSupervision 相关字段。根据审查规则,Dubbo 服务提供者 Remote 接口中的已有请求参数变更视为危险实现。
    • 影响分析:API 层的 DTO 修改如果没有严格管理 serialVersionUID,在服务提供者和消费者发版时间不一致时,极易引发 Java 反序列化异常(InvalidClassException),导致线上 RPC 调用大面积失败。
    • 优化建议:
      1. 检查修改的 DTO 类是否显式定义了固定的 serialVersionUID。如果没有,强烈建议补充,防止自动生成策略因字段增加而改变 UID。
      2. 评估该 DTO 是否作为入参。如果是入参,需确保消费者传递该字段时,提供者已经发布;如果是出参,需确保消费者能兼容未知字段(通常 JSON 序列化可兼容,但原生 Dubbo 序列化需谨慎)。

    二、评分明细

    • 功能实现的正确性与健壮性(22/40分): 扣分较多。代码中存在两处明显的逻辑硬伤:一是场景版本与枚举映射写反;二是列表过滤条件查不到数据时未做闭环处理,存在导致过滤条件失效的严重隐患。

    • 安全性与潜在风险(22/30分): 触碰了核心规则中关于 Dubbo RPC 接口参数变更的红线。API 模块的实体类变更存在潜在的反序列化阻断风险,需严格评估上下游发版依赖。

    • 最佳实践与可维护性(12/20分): 在 StaffDailyReportHuaweiService.java 中,针对 flightSupervision 的 Stream 过滤逻辑(约 150 字符的冗长代码)被一字不差地复制粘贴了 6 次。严重违反了 DRY(Don't Repeat Yourself)原则,建议将其提取为私有辅助方法。

    • 性能与资源利用(4/5分): 整体性能无明显瓶颈,但在大量循环内部频繁进行 Stream 过滤操作,在数据量较大时会有一定的 CPU 消耗,属于可接受范围。

    • 提交信息质量(5/5分): Commit 信息非常优秀。采用了 feat: 前缀,且通过多行列表清晰地描述了修改的背景、涉及的模块以及具体的实现逻辑,具备极高的可追溯性。

    总分:65分

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