|
@@ -282,6 +282,7 @@ public class ZeroTrustAuthApplyBusinessImpl implements IZeroTrustAuthApplyBusine
|
|
|
private Result<List<ServiceResourceDTO>> validateServiceInfos(List<ServiceResourceDTO> serviceInfos, List<ApiServiceAuthContentVo> contents) {
|
|
|
Map<String, List<ServiceResourceDTO>> collect = serviceInfos.stream()
|
|
|
.collect(Collectors.groupingBy(ServiceResourceDTO::getAppCode));
|
|
|
+ List<ServiceResourceDTO> errList = new ArrayList<>();
|
|
|
for (ApiServiceAuthContentVo authVo : contents) {
|
|
|
String appCode = authVo.getAppCode();
|
|
|
List<ServiceResourceDTO> exist = collect.get(appCode);
|
|
@@ -292,7 +293,7 @@ public class ZeroTrustAuthApplyBusinessImpl implements IZeroTrustAuthApplyBusine
|
|
|
dto.setServiceCode(e);
|
|
|
return dto;
|
|
|
}).collect(Collectors.toList());
|
|
|
- return Result.fail(ResultEnum.FAIL.getValue(), AuthApplyRespEnum.SERVICE_NOT_EXIST.getValue(), notExist);
|
|
|
+ errList.addAll(notExist);
|
|
|
}
|
|
|
Set<String> existCodes = exist.stream().map(ServiceResourceDTO::getServiceCode).collect(Collectors.toSet());
|
|
|
List<ServiceResourceDTO> notExist = authServiceCodes.stream().filter(e -> !existCodes.contains(e)).map(e -> {
|
|
@@ -301,10 +302,14 @@ public class ZeroTrustAuthApplyBusinessImpl implements IZeroTrustAuthApplyBusine
|
|
|
return dto;
|
|
|
}).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(notExist)) {
|
|
|
- return Result.fail(ResultEnum.FAIL.getValue(), AuthApplyRespEnum.SERVICE_NOT_EXIST.getValue(), notExist);
|
|
|
+ errList.addAll(notExist);
|
|
|
}
|
|
|
}
|
|
|
- return Result.success();
|
|
|
+ if (!errList.isEmpty()) {
|
|
|
+ return Result.fail(ResultEnum.FAIL.getValue(), AuthApplyRespEnum.SERVICE_NOT_EXIST.getValue(), errList);
|
|
|
+ } else {
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private ZeroTrustDataRespVO<AuthApplyRespVo> getErrorApplyResp(AuthApplyRespEnum authApplyRespEnum, Object content) {
|
|
@@ -399,6 +404,7 @@ public class ZeroTrustAuthApplyBusinessImpl implements IZeroTrustAuthApplyBusine
|
|
|
private Result<List<RoleInfo>> validateApplyRoles(List<ApplyInfoVo> applyInfoVos, List<RoleInfo> roleInfos, List<ApiRoleAuthContentVo> contents) {
|
|
|
Map<String, ApplyInfoVo> appMap = applyInfoVos.stream().collect(Collectors.toMap(ApplyInfoVo::getApplyCode, e -> e));
|
|
|
Map<String, List<RoleInfo>> roleMap = roleInfos.stream().collect(Collectors.groupingBy(RoleInfo::getAppId));
|
|
|
+ List<RoleInfo> errList = new ArrayList<>();
|
|
|
for (ApiRoleAuthContentVo authVo : contents) {
|
|
|
String appCode = authVo.getAppCode();
|
|
|
List<String> appRoleCodes = authVo.getRoleCodes();
|
|
@@ -406,16 +412,20 @@ public class ZeroTrustAuthApplyBusinessImpl implements IZeroTrustAuthApplyBusine
|
|
|
List<RoleInfo> roles = roleMap.get(applyInfoVo.getId());
|
|
|
if (CollectionUtils.isEmpty(roles)) {
|
|
|
List<RoleInfo> notExistRoles = mapNotExistRoles(appRoleCodes, applyInfoVo);
|
|
|
- return Result.fail(ResultEnum.FAIL.getValue(), AuthApplyRespEnum.ROLE_NOT_EXIST.getValue(), notExistRoles);
|
|
|
+ errList.addAll(notExistRoles);
|
|
|
}
|
|
|
Set<String> exist = roles.stream().map(RoleInfo::getCode).collect(Collectors.toSet());
|
|
|
List<String> notExist = appRoleCodes.stream().filter(e -> !exist.contains(e)).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isEmpty(notExist)) {
|
|
|
List<RoleInfo> notExistRoles = mapNotExistRoles(notExist, applyInfoVo);
|
|
|
- return Result.fail(ResultEnum.FAIL.getValue(), AuthApplyRespEnum.ROLE_NOT_EXIST.getValue(), notExistRoles);
|
|
|
+ errList.addAll(notExistRoles);
|
|
|
}
|
|
|
}
|
|
|
- return Result.success();
|
|
|
+ if (!errList.isEmpty()) {
|
|
|
+ return Result.fail(ResultEnum.FAIL.getValue(), AuthApplyRespEnum.ROLE_NOT_EXIST.getValue(), errList);
|
|
|
+ } else {
|
|
|
+ return Result.success();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private static List<RoleInfo> mapNotExistRoles(List<String> appRoleCodes, ApplyInfoVo applyInfoVo) {
|