feature(权限点): 树形查询支持层级参数;字段扩展
This commit is contained in:
parent
448634b3b5
commit
76382d63d3
@ -52,9 +52,35 @@ public class PermissionPointTreeNode implements IBaseTree<PermissionPointTreeNod
|
||||
* 授权策略类型,允许为空 1-平台授权型 2-客户授权型 3-免授权型
|
||||
*/
|
||||
private Integer delegatedType;
|
||||
|
||||
/** 图标 **/
|
||||
private String icon;
|
||||
|
||||
/** 页面路由地址 **/
|
||||
private String linkUrl;
|
||||
|
||||
/** 链接类型 1-PC 2-小程序 4-原生 **/
|
||||
private String linkType;
|
||||
|
||||
/** 扩展字段 **/
|
||||
private String linkExt;
|
||||
|
||||
/** 小程序ID **/
|
||||
private String microAppItemId;
|
||||
|
||||
/** 下级节点 **/
|
||||
private List<PermissionPointTreeNode> children;
|
||||
|
||||
/**
|
||||
* 网关专属字段,所属应用
|
||||
*/
|
||||
private String appName;
|
||||
|
||||
/**
|
||||
* 网关专属字段 ,功能URL,对应后端接口url
|
||||
*/
|
||||
private String featureUrl;
|
||||
|
||||
|
||||
@JsonIgnore
|
||||
@Override
|
||||
|
||||
@ -33,8 +33,9 @@ public class PermissionPointTreeQueryReq {
|
||||
/** 权限点terminal对应workspaceType **/
|
||||
private List<String> workspaceType;
|
||||
|
||||
/** 权限点元素类型
|
||||
* 0.菜单 1.页面 3按钮
|
||||
/**
|
||||
* 过滤层级-包含顶层两级
|
||||
* 1-工作台类型 2-工作台
|
||||
* **/
|
||||
private Integer featureType;
|
||||
private Integer maxLevel;
|
||||
}
|
||||
|
||||
@ -91,9 +91,30 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
List<PermissionPointTreeNode> resultTree = buildTopNodes(nodesResult, needAllTop);
|
||||
watch.stop();
|
||||
log.info("permission-point-tree cost:{}", watch.prettyPrint());
|
||||
//层级过滤
|
||||
filterLevel(resultTree, request.getMaxLevel(), 1);
|
||||
return resultTree;
|
||||
}
|
||||
|
||||
private void filterLevel(List<PermissionPointTreeNode> resultTree, Integer maxLevel, Integer currentLevel) {
|
||||
if (maxLevel == null || resultTree == null) {
|
||||
return;
|
||||
}
|
||||
if (currentLevel < maxLevel) {
|
||||
//递归子级
|
||||
for (PermissionPointTreeNode node : resultTree) {
|
||||
filterLevel(node.getChildren(), maxLevel, currentLevel + 1);
|
||||
}
|
||||
} else {
|
||||
//清空下级
|
||||
for (PermissionPointTreeNode node : resultTree) {
|
||||
node.setChildren(null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private List<PermissionPointTreeNode> buildTopNodes(List<PermissionPointTreeNode> nodesResult, boolean needAllTop) {
|
||||
//构建workspace-terminal工作台层级
|
||||
|
||||
@ -451,17 +472,11 @@ public class PermissionPointServiceImpl implements PermissionPointService {
|
||||
}
|
||||
|
||||
private PermissionPointTreeNode feature2Node(SaasFeature feature) {
|
||||
PermissionPointTreeNode node = new PermissionPointTreeNode();
|
||||
PermissionPointTreeNode node = BeanMapper.copyBean(feature, PermissionPointTreeNode.class);
|
||||
node.setPermissionPointId(feature.getId());
|
||||
node.setPermissionName(feature.getFeatureName());
|
||||
node.setCode(feature.getFeatureCode());
|
||||
node.setParentId(feature.getParentId());
|
||||
node.setTerminal(feature.getTerminal());
|
||||
node.setFeatureType(feature.getFeatureType());
|
||||
node.setFeatureTypeDesc(FeatureType.apply(feature.getFeatureType()).getDesc());
|
||||
node.setDelegatedType(feature.getDelegatedType());
|
||||
node.setPath(feature.getPath());
|
||||
node.setSort(feature.getSort());
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,8 @@ public class PermissionPointTest {
|
||||
//request.setKeyword("预警");
|
||||
//request.setWorkspaceType(Arrays.asList("ent"));
|
||||
//request.setTerminalList(Arrays.asList("NT_CMS_WEB_ENT_ZB"));
|
||||
request.setDelegateType(2);
|
||||
request.setDelegateType(0);
|
||||
request.setMaxLevel(3);
|
||||
ApiResult<List<PermissionPointTreeNode>> result = controller.listTreeNodes(request);
|
||||
System.out.println("---------------");
|
||||
System.out.println(JSON.toJSONString(result, SerializerFeature.DisableCircularReferenceDetect));
|
||||
|
||||
Loading…
Reference in New Issue
Block a user