yyhhblog

1、

/*建立树形结构*/
public List<Department> builTree(){
List<Department> treeMenus =new ArrayList<Department>();
for(Department menuNode : getRootNode()) {
menuNode=buildChilTree(menuNode);
treeMenus.add(menuNode);
}
return treeMenus;
}

/*递归,建立子树形结构*/
private Department buildChilTree(Department pNode){
List<Department> chilMenus =new ArrayList<Department>();
for(Department menuNode : menuList) {
if(menuNode.getParentId().equals(pNode.getId())) {
chilMenus.add(buildChilTree(menuNode));
}
}
pNode.setChildren(chilMenus);
return pNode;
}

/*获取根节点*/
private List<Department> getRootNode() {
List<Department> rootMenuLists =new ArrayList<Department>();
for(Department menuNode : menuList) {
if(menuNode.getParentId().equals("1")) {
rootMenuLists.add(menuNode);
}
}
return rootMenuLists;
}
builTree();

2、

/*建立全部树形结构*/
List<FuncConfig> buildChilTree(String parentId){
List<FuncConfig> list = funcConfigMapper.getFuncParentId(parentId);
for(FuncConfig funcConfigVo : list) {
String id = funcConfigVo.getId();
List<FuncConfig> child = buildChilTree(id);
if(!child.isEmpty()) {
funcConfigVo.setChildren(child);
}
}
return list;
}

 

分类:

技术点:

相关文章:

  • 2021-10-12
  • 2022-12-23
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-07-14
  • 2021-06-27
  • 2021-07-02
猜你喜欢
  • 2022-12-23
  • 2021-07-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-14
  • 2022-01-06
相关资源
相似解决方案