当前位置:网站首页>建立树形结构
建立树形结构
2022-08-03 04:35:00 【Dzooooone_】
//建立树形结构
public List<BasicMenuInfoVo> buildTree() {
List<BasicMenuInfoVo> treeMenus = new ArrayList<>();
for (BasicMenuInfoVo menuNode : getRootNode()) {
menuNode = buildChildTree(menuNode);
treeMenus.add(menuNode);
}
return treeMenus;
}
//获取根节点
private List<BasicMenuInfoVo> getRootNode() {
List<BasicMenuInfoVo> rootMenuLists = new ArrayList<>();
for (BasicMenuInfoVo menuNode : menuList) {
if (menuNode.getParentId().longValue() == 0) {
menuNode.setAccess(permissionMap.get(menuNode.getPermissionId()));
if (flag == 0) rootMenuLists.add(menuNode);
if (flag == 1 && menuNode.getState() == 1) rootMenuLists.add(menuNode);
}
}
return rootMenuLists;
}
//递归,建立子树形结构
private BasicMenuInfoVo buildChildTree(BasicMenuInfoVo pNode) {
List<BasicMenuInfoVo> childMenus = new ArrayList<>();
for (BasicMenuInfoVo menuNode : menuList) {
if (menuNode.getParentId().longValue() == pNode.getId().longValue()) {
menuNode.setAccess(permissionMap.get(menuNode.getPermissionId()));
if (flag == 0) childMenus.add(buildChildTree(menuNode));
if (flag == 1 && menuNode.getState() == 1) childMenus.add(buildChildTree(menuNode));
}
}
pNode.setRoutes(childMenus);
return pNode;
}
边栏推荐
猜你喜欢
StarRocks 7 月社区动态
【生物素叠氮化物|cas:908007-17-0】价格_厂家
Concepts and Methods of Exploratory Testing
工程水文学试题库
DFS对剪枝的补充
install ambari
【Harmony OS】【FAQ】Hongmeng Questions Collection 1
Redis缓存雪崩、缓存穿透、缓存击穿
Shenzhen Offline Registration|StarRocks on AWS: How to conduct rapid and unified analysis of real-time data warehouses
常见荧光染料修饰多种基团及其激发和发射波长数据一览数据
随机推荐
Shell条件语句判断
Can Oracle EMCC be installed independently?Or does it have to be installed on the database server?
[Developers must see] [push kit] Collection of typical problems of push service service 2
【翻译】开发与生产中的Kubernetes修复成本对比
链动2+1模式简单,奖励结构丰厚,自主裂变?
探索性测试的概念及方法
【Harmony OS】【ArkUI】ets开发 图形与动画绘制
redis键值出现 xacxedx00x05tx00&的解决方法
DC-4靶场搭建及渗透实战详细过程(DC靶场系列)
富瑞宣布战略交易,以简化运营,持续专注于打造领先的独立全服务型全球投行公司
excerpt from compilation book
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
私域流量引流方法?分享购火爆的商业模式,你值得拥有
工程制图-齿轮
【生物素叠氮化物|cas:908007-17-0】价格_厂家
Problems that need to be solved for interrupting the system
常见亲脂性细胞膜染料DiO, Dil, DiR, Did光谱图和实验操作流程
Assembly answers
测试人员的价值体现在哪里
多肽介导PEG磷脂——靶向功能材料之DSPE-PEG-RGD/TAT/NGR/APRPG