当前位置:网站首页>Create a tree structure
Create a tree structure
2022-08-03 04:41:00 【Dzooooone_】
//Create a tree structurepublic List buildTree() {List treeMenus = new ArrayList<>();for (BasicMenuInfoVo menuNode : getRootNode()) {menuNode = buildChildTree(menuNode);treeMenus.add(menuNode);}return treeMenus;}//get root nodeprivate List getRootNode() {List 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;}// recursively, create a subtree structureprivate BasicMenuInfoVo buildChildTree(BasicMenuInfoVo pNode) {List 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;}
边栏推荐
- 12.机器学习基础:评估机器学习模型
- Live | StarRocks technology insider: low base dictionary global optimization
- Browser listens for tab closing
- Technology Sharing | How to do assertion verification for xml format in interface automation testing?
- 2022/08/02 Study Notes (day22) Multithreading
- 2022 Henan Mengxin League Game (4): Zhengzhou University of Light Industry E - Sleep Well
- Interface Test Framework Practice (4) | Get Schema Assertion
- DFS's complement to pruning
- 我将GuiLite移植到了STM32F4开发板上
- 建立树形结构
猜你喜欢
记录一些遇见的bug——mapstruct和lombok同时使用时,转换实体类时数据丢失问题
How many moments have you experienced the collapse of electronic engineers?
安装ambari
Windows 安装PostgreSQL
t conditional judgment statement and if loop
【生物素叠氮化物|cas:908007-17-0】价格_厂家
Redis缓存雪崩、缓存穿透、缓存击穿
unity2D横板游戏教程6-敌人AI以及受击动画
BIOTIN ALKYNE CAS:773888-45-2价格,供应商
【Harmony OS】【ArkUI】ets开发 基础页面布局与数据连接
随机推荐
【Harmony OS】【ARK UI】ets使用startAbility或startAbilityForResult方式调起Ability
技术分享 | 接口自动化测试中如何对xml 格式做断言验证?
8.电影评论分类:二分类问题
用户密码加密工具
数据库基本概述与SQL概述
Interface Test Framework Practice (4) | Get Schema Assertion
DDL操作数据库、表、列
Flink state
t条件判断语句与if循环
表的创建、修改与删除
Technology Sharing | How to do assertion verification for xml format in interface automation testing?
社交电商:流量红利已尽,裂变营销是最低成本的获客之道
2022/08/02 学习笔记 (day22) 多线程
自组织是管理者和成员的双向奔赴
Live | StarRocks technology insider: low base dictionary global optimization
5.回顾简单的神经网络
10.预测房价:回归问题
汇编题答案
社交电商:链动2+1模式,为什么能在电商行业生存那么久?
我将GuiLite移植到了STM32F4开发板上