//跳角色列表
@RequestMapping("sysadmin/userAction_toModule")
public String toModuleList(){
return "sysadmin/role/jRoleModule";
}
@RequestMapping("sysadmin/roleAction_roleModuleJsonStr")
@ResponseBody
public List<Map<String, Object>> toModuleRole(String id) throws Exception{
//查询所有的角色
List<Map<String, Object>> moduleList = moduleService.findAllRoleModule();
//新建一个集合封装父节点信息
List<Map<String, Object>> parentList = Lists.newArrayList();
//遍历所有权限信息
for (Map<String, Object> map : moduleList) {
//将父节点,即是layerNum==1的权限遍历添加到parentList 父节点数组中
if (map.get("layerNum").equals("1")) {
parentList.add(map);
}
}
//
recursionChildren(parentList, moduleList);
return parentList;
}
// 递归获取子节点数据
//List<Map<String, Object>> parentList 表示父节点集合 key
//List<Map<String, Object>> allList 表示每个父节点中的集合值 value
public List<Map<String, Object>> recursionChildren (List<Map<String, Object>> parentList,
List<Map<String, Object>> allList) {
//新建一个集合封装子节点信息
List<Map<String, Object>> childrenList = null;
//用parentMap遍历子节点的父节点,将每个父节点的值,即是key 装入每个parentMap中
for (Map<String, Object> parentMap : parentList) {
childrenList= new ArrayList();
//用allMap遍历子节点的值,将每个子节点的值,即是value 装入每个allMap中
for (Map<String, Object> allMap : allList) {
//当子类的moduleId首字母和父类的moduleId首字母相等时,就添加子类
if ((allMap.get("parentId")).equals(parentMap.get("moduleId"))) {
childrenList.add(allMap);
}
}
//如果递归得到的结果不为空,将其添加到childrenList中
if (childrenList!=null) {
parentMap.put("children", childrenList);
recursionChildren(childrenList, allList);
}
}
return childrenList;
}
@RequestMapping("sysadmin/userAction_toModule")
public String toModuleList(){
return "sysadmin/role/jRoleModule";
}
@RequestMapping("sysadmin/roleAction_roleModuleJsonStr")
@ResponseBody
public List<Map<String, Object>> toModuleRole(String id) throws Exception{
//查询所有的角色
List<Map<String, Object>> moduleList = moduleService.findAllRoleModule();
//新建一个集合封装父节点信息
List<Map<String, Object>> parentList = Lists.newArrayList();
//遍历所有权限信息
for (Map<String, Object> map : moduleList) {
//将父节点,即是layerNum==1的权限遍历添加到parentList 父节点数组中
if (map.get("layerNum").equals("1")) {
parentList.add(map);
}
}
//
recursionChildren(parentList, moduleList);
return parentList;
}
// 递归获取子节点数据
//List<Map<String, Object>> parentList 表示父节点集合 key
//List<Map<String, Object>> allList 表示每个父节点中的集合值 value
public List<Map<String, Object>> recursionChildren (List<Map<String, Object>> parentList,
List<Map<String, Object>> allList) {
//新建一个集合封装子节点信息
List<Map<String, Object>> childrenList = null;
//用parentMap遍历子节点的父节点,将每个父节点的值,即是key 装入每个parentMap中
for (Map<String, Object> parentMap : parentList) {
childrenList= new ArrayList();
//用allMap遍历子节点的值,将每个子节点的值,即是value 装入每个allMap中
for (Map<String, Object> allMap : allList) {
//当子类的moduleId首字母和父类的moduleId首字母相等时,就添加子类
if ((allMap.get("parentId")).equals(parentMap.get("moduleId"))) {
childrenList.add(allMap);
}
}
//如果递归得到的结果不为空,将其添加到childrenList中
if (childrenList!=null) {
parentMap.put("children", childrenList);
recursionChildren(childrenList, allList);
}
}
return childrenList;
}









