package com.lxzn.base.service.support; import com.lxzn.framework.domain.base.ext.MultilevelDictionaryExt; import com.lxzn.framework.model.response.CommonJsonTree; import java.util.ArrayList; import java.util.List; public class DictionaryTreeWrapper { public static List loadTree(List componentInfoList) { List tree = new ArrayList();// TreeNode集合,存放所有树对象。 CommonJsonTree node; for(MultilevelDictionaryExt ext : componentInfoList) { node = new CommonJsonTree(); node.setId(ext.getDicId()); node.setLabel(ext.getDicName()); node.setParentId(null); //设置菜单节点图标 Start String iconStr = ""; /*判断是否设置了菜单导航图标样式*/ if (!ext.hasChild()) {//导航页面的菜单节点 iconStr = "";//默认图标 } node.setIconClass(iconStr); node.setRField(ext.getTypeCode()); node = loadChildrenNodes(ext, node); tree.add(node); } return tree; } private static CommonJsonTree loadChildrenNodes(MultilevelDictionaryExt info, CommonJsonTree node) { if(info.hasChild()) { List children = info.getChildList(); CommonJsonTree childNode; for (MultilevelDictionaryExt ext : children) { childNode = new CommonJsonTree(); childNode.setId(ext.getDicId()); childNode.setLabel(ext.getDicName()); childNode.setParentId(ext.getParentId()); //设置菜单节点图标 Start String iconStr = ""; /*判断是否设置了菜单导航图标样式*/ if (!ext.hasChild()) {//导航页面的菜单节点 iconStr = "";//默认图标 } childNode.setIconClass(iconStr); childNode.setRField(ext.getTypeCode()); childNode = loadChildrenNodes(ext, childNode); node.addChildren(childNode); } } return node; } }