feat(REQ-2545): 查询权限点接口增加权限类型(是否是featureResource)
This commit is contained in:
parent
de108e0c68
commit
6c50de8e93
@ -1,9 +1,11 @@
|
||||
package cn.axzo.tyr.client.model.res;
|
||||
|
||||
import cn.axzo.tyr.client.model.enums.IdentityType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
@ -66,8 +68,22 @@ public class ListPermissionFromRoleGroupResp {
|
||||
*/
|
||||
private Set<Long> simpleFeatureInfos;
|
||||
|
||||
/**
|
||||
* 权限点及是否为新旧权限点
|
||||
*/
|
||||
private Set<FeatureInfo> featureInfos;
|
||||
|
||||
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public static class FeatureInfo {
|
||||
private Long featureId;
|
||||
/** 0:saas_feature,1:saas_feature_resource **/
|
||||
private Integer relationType;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -43,22 +43,9 @@ import cn.axzo.tyr.client.model.vo.SaasPermissionGroupVO;
|
||||
import cn.axzo.tyr.client.model.vo.SaasRoleVO;
|
||||
import cn.axzo.tyr.server.model.FilterRoleAuth;
|
||||
import cn.axzo.tyr.server.model.PermissionCacheKey;
|
||||
import cn.axzo.tyr.server.repository.dao.ProductModuleDao;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasFeatureDao;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasProductModuleFeatureRelationDao;
|
||||
import cn.axzo.tyr.server.repository.entity.ProductFeatureInfo;
|
||||
import cn.axzo.tyr.server.repository.entity.ProductFeatureQuery;
|
||||
import cn.axzo.tyr.server.repository.entity.RolePermission;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeature;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasFeatureResource;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasPageElementFeatureResourceRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasPgroupPermissionRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRole;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroup;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleGroupRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleWithUser;
|
||||
import cn.axzo.tyr.server.repository.entity.*;
|
||||
import cn.axzo.tyr.server.repository.mapper.TyrSaasAuthMapper;
|
||||
import cn.axzo.tyr.server.service.PermissionCacheService;
|
||||
import cn.axzo.tyr.server.service.PermissionPointService;
|
||||
@ -83,6 +70,7 @@ import cn.hutool.core.util.BooleanUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
@ -1040,12 +1028,15 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
if (!listPermissionFromRoleGroupReq.getFindFeatureInfo()) {
|
||||
return permissionInfo;
|
||||
}
|
||||
Map<Long, Set<Long>> authMap = filterAuthByRoleAndProduct(permissionInfo.stream().map(e -> FilterRoleAuth.builder()
|
||||
Map<Long, Set<ListPermissionFromRoleGroupResp.FeatureInfo>> authMap = filterAuthByRoleAndProduct(permissionInfo.stream().map(e -> FilterRoleAuth.builder()
|
||||
.roleId(NumberUtil.parseLong(e.getRoleId()))
|
||||
.workspaceId(e.getWorkspaceId())
|
||||
.build()).collect(Collectors.toList()));
|
||||
|
||||
permissionInfo.forEach(e -> e.setSimpleFeatureInfos(authMap.get(NumberUtil.parseLong(e.getRoleId()))));
|
||||
permissionInfo.forEach(e -> e.setFeatureInfos(authMap.get(NumberUtil.parseLong(e.getRoleId()))));
|
||||
permissionInfo.forEach(e -> e.setSimpleFeatureInfos(org.apache.commons.collections4.CollectionUtils.emptyIfNull(authMap.get(NumberUtil.parseLong(e.getRoleId())))
|
||||
.stream().map(ListPermissionFromRoleGroupResp.FeatureInfo::getFeatureId).collect(Collectors.toSet())));
|
||||
|
||||
return permissionInfo;
|
||||
}
|
||||
|
||||
@ -1055,7 +1046,7 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
* @param filterRoleAuths
|
||||
* @return KEY :role Id ; VALUE: feature id ;
|
||||
*/
|
||||
public Map<Long, Set<Long>> filterAuthByRoleAndProduct(List<FilterRoleAuth> filterRoleAuths) {
|
||||
public Map<Long, Set<ListPermissionFromRoleGroupResp.FeatureInfo>> filterAuthByRoleAndProduct(List<FilterRoleAuth> filterRoleAuths) {
|
||||
List<Long> roleIds = filterRoleAuths.stream().map(FilterRoleAuth::getRoleId).distinct().collect(Collectors.toList());
|
||||
|
||||
|
||||
@ -1075,9 +1066,10 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
List<ProductFeatureRelationVO> productsDetail = RpcExternalUtil.rpcApiResultProcessor(() -> productFeatureRelationService.featureListByProduct(productIds), " find permission point by product ", productIds);
|
||||
Map<Long, Map<String, List<ProductFeatureRelationVO>>> productGroup = productsDetail.stream().collect(Collectors.groupingBy(ProductFeatureRelationVO::getProductModuleId, Collectors.groupingBy(ProductFeatureRelationVO::getDictCode)));
|
||||
|
||||
Map<Long, ProductFeatureRelationVO> featureRelationVoMap = productsDetail.stream().collect(Collectors.toMap(ProductFeatureRelationVO::getFeatureId, Function.identity(), (v1, v2) -> v1));
|
||||
|
||||
// intersection auth from role and product
|
||||
return filterRoleAuths.stream().collect(Collectors.toMap(FilterRoleAuth::getRoleId, e -> {
|
||||
Map<Long, Set<Long>> map = filterRoleAuths.stream().collect(Collectors.toMap(FilterRoleAuth::getRoleId, e -> {
|
||||
Long roleId = e.getRoleId();
|
||||
SaasRoleVO saasRole = roleMap.get(e.getRoleId());
|
||||
if (null == saasRole) {
|
||||
@ -1114,6 +1106,17 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
oldFeatureLists.addAll(newFeatureLists);
|
||||
return oldFeatureLists;
|
||||
}));
|
||||
|
||||
Map<Long, Set<ListPermissionFromRoleGroupResp.FeatureInfo>> featureMap = Maps.newHashMap();
|
||||
for (Map.Entry<Long, Set<Long>> entry : map.entrySet()) {
|
||||
Set<ListPermissionFromRoleGroupResp.FeatureInfo> featureInfos = org.apache.commons.collections4.CollectionUtils.emptyIfNull(entry.getValue()).stream().map(e -> ListPermissionFromRoleGroupResp.FeatureInfo.builder()
|
||||
.featureId(e)
|
||||
.relationType(Optional.ofNullable(featureRelationVoMap.get(e)).map(ProductFeatureRelationVO::getType).orElse(null))
|
||||
.build()).collect(Collectors.toSet());
|
||||
featureMap.put(entry.getKey(), featureInfos);
|
||||
}
|
||||
|
||||
return featureMap;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
Loading…
Reference in New Issue
Block a user