refactor(code2identity): 产品权限增加过滤参建类型
This commit is contained in:
parent
ce880c2686
commit
c122e565d7
@ -16,7 +16,10 @@ import java.util.Set;
|
||||
public class ProductFeatureQuery {
|
||||
|
||||
private Set<Long> productIds;
|
||||
|
||||
private List<String> featureCodes;
|
||||
|
||||
private String terminal;
|
||||
|
||||
private Integer workspaceJoinType;
|
||||
}
|
||||
|
||||
@ -4,6 +4,8 @@ import cn.axzo.framework.domain.web.result.ApiResult;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationSearchReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationVO;
|
||||
import cn.axzo.tyr.server.repository.entity.ProductFeatureQuery;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -28,4 +30,6 @@ public interface ProductFeatureRelationService {
|
||||
* @return
|
||||
*/
|
||||
Map<Long, List<ProductFeatureRelationVO>> getByWorkspace(Set<Long> workspaceId);
|
||||
|
||||
List<SaasProductModuleFeatureRelation> queryOnCondition(ProductFeatureQuery condition);
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import cn.axzo.tyr.client.model.permission.PermissionPointTreeNode;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationSearchReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationUpdateReq;
|
||||
import cn.axzo.tyr.client.model.product.ProductFeatureRelationVO;
|
||||
import cn.axzo.tyr.server.repository.entity.ProductFeatureQuery;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasProductModuleFeatureRelation;
|
||||
import cn.axzo.tyr.server.repository.dao.SaasProductModuleFeatureRelationDao;
|
||||
import cn.axzo.tyr.server.service.ProductFeatureRelationService;
|
||||
@ -16,6 +17,7 @@ import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.StopWatch;
|
||||
import cn.hutool.core.stream.SimpleCollector;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -144,5 +146,15 @@ public class ProductFeatureRelationServiceImpl implements ProductFeatureRelation
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SaasProductModuleFeatureRelation> queryOnCondition(ProductFeatureQuery condition) {
|
||||
LambdaQueryWrapper<SaasProductModuleFeatureRelation> wrapper = new LambdaQueryWrapper<SaasProductModuleFeatureRelation>()
|
||||
.in(CollectionUtil.isNotEmpty(condition.getProductIds()),
|
||||
SaasProductModuleFeatureRelation::getProductModuleId, condition.getProductIds())
|
||||
.eq(Objects.nonNull(condition.getWorkspaceJoinType()),
|
||||
SaasProductModuleFeatureRelation::getDictCode, condition.getWorkspaceJoinType());
|
||||
return this.saasProductModuleFeatureRelationDao.list(wrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -32,6 +32,7 @@ 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.SaasProductModuleFeatureRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRole;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleUserRelation;
|
||||
import cn.axzo.tyr.server.repository.entity.SaasRoleWithUser;
|
||||
@ -534,9 +535,9 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
//code查询权限点信息
|
||||
List<SaasFeature> features = permissionPointService.listNodeByCode(req.getFeatureCode(), req.getTerminal());
|
||||
//权限匹配 - 工作台是否有指定权限
|
||||
List<SaasFeature> matchedFeature = matchWorkspaceFeature(req.getWorkspaceId(), features);
|
||||
List<SaasFeature> matchedFeature = matchWorkspaceFeature(req.getWorkspaceId(), req.getWorkspaceJoinType(), features);
|
||||
if (CollectionUtil.isEmpty(matchedFeature)) {
|
||||
log.info("no matched feature in workspace");
|
||||
log.warn("no matched feature in workspace");
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -545,7 +546,7 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
.filter(f -> DelegatedType.NO_NEED.sameCode(f.getDelegatedType()))
|
||||
.findAny();
|
||||
if (freeFeature.isPresent()) {
|
||||
log.info("free feature found");
|
||||
log.warn("free feature found");
|
||||
result.setFreePermission(true);
|
||||
return result;
|
||||
}
|
||||
@ -556,18 +557,22 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SaasFeature> matchWorkspaceFeature(Long workspaceId, List<SaasFeature> features) {
|
||||
//查询工作台下产品-产品包含的权限
|
||||
private List<SaasFeature> matchWorkspaceFeature(Long workspaceId, Integer workspaceJoinType, List<SaasFeature> features) {
|
||||
//查询工作台下产品
|
||||
List<ServicePkgProduct> productList = checkAndGetData(servicePkgClient.listProductInWorkSpace(workspaceId));
|
||||
if (CollectionUtil.isEmpty(productList)) {
|
||||
log.warn("no product found for workspace:{}", workspaceId);
|
||||
return new ArrayList<>();
|
||||
}
|
||||
Set<Long> workspaceFeatures = checkAndGetData(productFeatureRelationService.featureListByProduct(productList.stream()
|
||||
.map(ServicePkgProduct::getProductId)
|
||||
.collect(Collectors.toList())))
|
||||
//产品包含的权限-过滤参建类型
|
||||
Set<Long> workspaceFeatures = productFeatureRelationService.queryOnCondition(ProductFeatureQuery.builder()
|
||||
.productIds(productList.stream()
|
||||
.map(ServicePkgProduct::getProductId)
|
||||
.collect(Collectors.toSet()))
|
||||
.workspaceJoinType(workspaceJoinType)
|
||||
.build())
|
||||
.stream()
|
||||
.map(ProductFeatureRelationVO::getFeatureId)
|
||||
.map(SaasProductModuleFeatureRelation::getFeatureId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
//权限匹配
|
||||
@ -619,18 +624,6 @@ public class TyrSaasAuthServiceImpl implements TyrSaasAuthService {
|
||||
return users;
|
||||
}
|
||||
|
||||
private Set<Long> listWorkspaceFeatures(Long workspaceId) {
|
||||
List<ServicePkgProduct> productList = checkAndGetData(servicePkgClient.listProductInWorkSpace(workspaceId));
|
||||
if (CollectionUtil.isEmpty(productList)) {
|
||||
log.warn("no product found for workspace:{}", workspaceId);
|
||||
return new HashSet<>();
|
||||
}
|
||||
List<ProductFeatureRelationVO> features = checkAndGetData(productFeatureRelationService.featureListByProduct(productList.stream()
|
||||
.map(ServicePkgProduct::getProductId)
|
||||
.collect(Collectors.toList())));
|
||||
return features.stream().map(ProductFeatureRelationVO::getFeatureId).collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ListIdentityFromPermissionResp> batchListIdentityFromPermission(List<ListIdentityFromPermissionReq> reqList) {
|
||||
//异步处理
|
||||
|
||||
Loading…
Reference in New Issue
Block a user