Merge remote-tracking branch 'origin/feature/REQ-2046' into feature/REQ-2046
This commit is contained in:
commit
81c0c6996a
@ -870,7 +870,6 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
permissionInfo.forEach(e -> e.setSimpleFeatureInfos(authMap.get(NumberUtil.parseLong(e.getRoleId()))));
|
||||
return permissionInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过工作台ID过滤指定角色的权限
|
||||
* @param filterRoleAuths
|
||||
@ -889,15 +888,16 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
// find product by workspace
|
||||
Set<Long> workspaceId = filterRoleAuths.stream().map(FilterRoleAuth::getWorkspaceId).collect(Collectors.toSet());
|
||||
List<ServicePkgDetailRes> servicePkgDetailRes = RpcExternalUtil.rpcProcessor(() -> servicePkgClient.getServicePkgDetailBySpaceId(workspaceId), "find product ", workspaceId);
|
||||
Map<Long, List<ServicePkgProduct>> productMap = servicePkgDetailRes.stream().collect(Collectors.toMap(ServicePkgDetailRes::getSpaceId, ServicePkgDetailRes::getProducts, (a, b) -> a));
|
||||
Map<Long, List<ServicePkgProduct>> workspaceMap = servicePkgDetailRes.stream().collect(Collectors.toMap(ServicePkgDetailRes::getSpaceId, ServicePkgDetailRes::getProducts, (a, b) -> a));
|
||||
|
||||
// find permission point by product
|
||||
List<Long> productIds = productMap.values().stream().flatMap(List::stream).map(ServicePkgProduct::getProductId).distinct().collect(Collectors.toList());
|
||||
List<Long> productIds = servicePkgDetailRes.stream().map(ServicePkgDetailRes::getProducts).flatMap(List::stream).map(ServicePkgProduct::getProductId).distinct().collect(Collectors.toList());
|
||||
List<ProductFeatureRelationVO> productsDetail = RpcExternalUtil.rpcApiResultProcessor(() -> productFeatureRelationService.featureListByProduct(productIds), " find permission point by product ", productIds);
|
||||
Map<Long, ProductFeatureRelationVO> productDetailMap = productsDetail.stream().collect(Collectors.toMap(ProductFeatureRelationVO::getProductModuleId, Function.identity(), (a, b) -> a));
|
||||
Map<Long, Map<String, List<ProductFeatureRelationVO>>> productGroup = productsDetail.stream().collect(Collectors.groupingBy(ProductFeatureRelationVO::getProductModuleId, Collectors.groupingBy(ProductFeatureRelationVO::getDictCode)));
|
||||
|
||||
|
||||
// intersection auth from role and product
|
||||
return filterRoleAuths.stream().collect(Collectors.toMap(FilterRoleAuth::getRoleId, e -> {
|
||||
return filterRoleAuths.stream().collect(Collectors.toMap(FilterRoleAuth::getRoleId, e -> {
|
||||
Long roleId = e.getRoleId();
|
||||
SaasRoleVO saasRole = roleMap.get(e.getRoleId());
|
||||
if (null == saasRole) {
|
||||
@ -905,29 +905,33 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
||||
Integer productUnitType = saasRole.getProductUnitType();
|
||||
List<ServicePkgProduct> productsInfo = productMap.get(e.getWorkspaceId());
|
||||
List<Long> allFeatureIds = productsInfo.stream().map(productSimpleInfo -> {
|
||||
ProductFeatureRelationVO productDetail = productDetailMap.get(productSimpleInfo.getProductId());
|
||||
if (!Objects.equals(productUnitType.toString(), productDetail.getDictCode())) {
|
||||
return null;
|
||||
}
|
||||
return productDetail.getFeatureId();
|
||||
}).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
|
||||
List<Long> currentPermissionId = saasRole.getMatchFeature(e.getWorkspaceId(), null).stream().map(PermissionPointTreeNode::getPermissionPointId).distinct().collect(Collectors.toList());
|
||||
List<ServicePkgProduct> servicePkgProducts = workspaceMap.get(e.getWorkspaceId());
|
||||
Set<Long> allFeatureIds = servicePkgProducts.stream().map(ServicePkgProduct::getProductId).distinct().map(productId ->
|
||||
{
|
||||
|
||||
Map<String, List<ProductFeatureRelationVO>> productUnitMap = productGroup.get(productId);
|
||||
if (null == productUnitMap) {
|
||||
return null;
|
||||
}
|
||||
List<ProductFeatureRelationVO> productFeatureRelationVO = productUnitMap.get(String.valueOf(saasRole.getProductUnitType()));
|
||||
if (CollectionUtil.isEmpty(productFeatureRelationVO)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return productFeatureRelationVO.stream().map(ProductFeatureRelationVO::getFeatureId).collect(Collectors.toSet());
|
||||
}
|
||||
).filter(Objects::nonNull).flatMap(Set::stream).collect(Collectors.toSet());
|
||||
|
||||
|
||||
List<Long> currentPermissionId = saasRole.getPermissionGroup().stream().map(SaasPermissionGroupVO::getFeature).flatMap(List::stream).map(PermissionPointTreeNode::getPermissionPointId).distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
return new HashSet<>(CollectionUtil.intersection(allFeatureIds, currentPermissionId));
|
||||
|
||||
},(a,b)->{
|
||||
a.addAll(b);
|
||||
return a;
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
|
||||
Loading…
Reference in New Issue
Block a user