public List<Map<String, Object>> createComboTreeChildren(List<SysMenu> list, String fid,String rootId) { List<Map<String, Object>> childList = new ArrayList<Map<String, Object>>(); for (int j = 0; j < list.size(); j++) { Map<String, Object> map = null; SysMenu treeChild = (SysMenu) list.get(j); if (treeChild.getParentId().equals(fid)) { map = new HashMap<String, Object>(); String id=treeChild.getId(); if(!id.equals(rootId)){ map.put("id", list.get(j).getId()); map.put("name", list.get(j).getName()); map.put("sort", list.get(j).getSort()); map.put("href", list.get(j).getHref()); map.put("is_show", list.get(j).getIsShow()); map.put("permission", list.get(j).getPermission()); map.put("parentId", list.get(j).getParentId()); } // if (!"0".equals(treeChild.getParentId())) {//判断是否是总菜单 // map.put("state", "closed"); // } map.put("children", createComboTreeChildren(list, treeChild.getId(),rootId)); // List childrenList = createComboTreeChildren(list, treeChild.getId()); // if(null==childList && 0==childList.size()){ // map.put("children", "childrenList"); // } } if (map != null) childList.add(map); } return childList; }
转载于:https://my.oschina.net/u/3743680/blog/1622827