递归获取树形结构数据

	/**
     * 获取树形表结构数据
     * @param list 表数据
     * @param parentId 父节点id
     * @return 树形数据
     */
    @ServiceLog("获取树形表结构数据")
    public List<Map<Object, Object>> getOrgTree(List<Map<Object, Object>> list, String parentId){
     
        List<Map<Object, Object>> dataList = new ArrayList<Map<Object,Object>>();
        for(Map<Object, Object> map:list){
     
            if(String.valueOf(map.get("parentId")).equals(parentId)){
     
                List<Map<Object, Object>> childrenList = getOrgTree(list, String.valueOf(map.get("organizationId")));
                map.put("children",childrenList);
                dataList.add(map);
            }
        }
        return dataList;
    }

你可能感兴趣的:(Java,Java)