package org.jeecg.modules.dnc.service.support;
|
|
|
import org.jeecg.modules.dnc.dto.DepartmentExt;
|
import org.jeecg.modules.dnc.response.CommonJsonTree;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
|
public class DepartmentTreeWrapper {
|
public static List<CommonJsonTree> loadTree(List<DepartmentExt> componentInfoList) {
|
List<CommonJsonTree> tree = new ArrayList<CommonJsonTree>();// TreeNode集合,存放所有树对象。
|
CommonJsonTree node;
|
for(DepartmentExt ext : componentInfoList) {
|
node = new CommonJsonTree();
|
node.setId(ext.getDepartId());
|
node.setLabel(ext.getDepartName());
|
node.setParentId(null);
|
//设置菜单节点图标 Start
|
String iconStr = "";
|
/*判断是否设置了菜单导航图标样式*/
|
if (!ext.hasChild()) {//导航页面的菜单节点
|
iconStr = "";//默认图标
|
}
|
node.setIconClass(iconStr);
|
node = loadChildrenNodes(ext, node);
|
tree.add(node);
|
}
|
return tree;
|
}
|
|
private static CommonJsonTree loadChildrenNodes(DepartmentExt info, CommonJsonTree node) {
|
if(info.hasChild()) {
|
List<DepartmentExt> children = info.getChildList();
|
CommonJsonTree childNode;
|
for (DepartmentExt ext : children) {
|
childNode = new CommonJsonTree();
|
childNode.setId(ext.getDepartId());
|
childNode.setLabel(ext.getDepartName());
|
childNode.setParentId(ext.getParentId());
|
//设置菜单节点图标 Start
|
String iconStr = "";
|
/*判断是否设置了菜单导航图标样式*/
|
if (!ext.hasChild()) {//导航页面的菜单节点
|
iconStr = "";//默认图标
|
}
|
childNode.setIconClass(iconStr);
|
childNode = loadChildrenNodes(ext, childNode);
|
node.addChildren(childNode);
|
}
|
}
|
return node;
|
}
|
}
|