2025年4月10日16:25:46
parent
b19988672a
commit
753e7083ba
|
|
@ -86,11 +86,11 @@ public class RoleController {
|
||||||
String desc = params.get("desc").toString();
|
String desc = params.get("desc").toString();
|
||||||
String type = params.get("type").toString();
|
String type = params.get("type").toString();
|
||||||
|
|
||||||
Role role ;
|
Role role;
|
||||||
|
|
||||||
if (id != null && !id.isEmpty()){
|
if (id != null && !id.isEmpty()) {
|
||||||
role = roleDao.findById(Long.parseLong(id)).get();
|
role = roleDao.findById(Long.parseLong(id)).get();
|
||||||
}else {
|
} else {
|
||||||
role = new Role();
|
role = new Role();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -130,38 +130,50 @@ public class RoleController {
|
||||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||||
|
|
||||||
for (Permission permission : permissionList) {
|
for (Permission permission : permissionList) {
|
||||||
if (permission.getParent() == null){
|
// if (permission.getParent() == null){
|
||||||
List<Permission> children = permission.getChildren();
|
// List<Permission> children = permission.getChildren();
|
||||||
|
//
|
||||||
|
// Map<String, Object> map = new HashMap<>();
|
||||||
|
// map.put("id", permission.getId());
|
||||||
|
// map.put("name", permission.getName());
|
||||||
|
// map.put("desc", permission.getDescription());
|
||||||
|
// map.put("url", permission.getUrl());
|
||||||
|
// map.put("sort", permission.getSort());
|
||||||
|
// map.put("parentId", permission.getParent() == null ? 0L : permission.getParent().getId());
|
||||||
|
//
|
||||||
|
// List<Map<String, Object>> childList = new ArrayList<>();
|
||||||
|
//
|
||||||
|
// if (!children.isEmpty()){
|
||||||
|
// for (Permission child : children) {
|
||||||
|
// if (permissionList.contains(child)){
|
||||||
|
// Map<String, Object> childMap = new HashMap<>();
|
||||||
|
// childMap.put("id", child.getId());
|
||||||
|
// childMap.put("name", child.getName());
|
||||||
|
// childMap.put("desc", child.getDescription());
|
||||||
|
// childMap.put("url", child.getUrl());
|
||||||
|
// childMap.put("sort", child.getSort());
|
||||||
|
// childMap.put("parentId", child.getParent() == null ? 0L : child.getParent().getId());
|
||||||
|
// childList.add(childMap);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// map.put("children", childList);
|
||||||
|
//
|
||||||
|
// resultList.add(map);
|
||||||
|
// }
|
||||||
|
|
||||||
Map<String, Object> map = new HashMap<>();
|
|
||||||
map.put("id", permission.getId());
|
|
||||||
map.put("name", permission.getName());
|
|
||||||
map.put("desc", permission.getDescription());
|
|
||||||
map.put("url", permission.getUrl());
|
|
||||||
map.put("sort", permission.getSort());
|
|
||||||
map.put("parentId", permission.getParent() == null ? 0L : permission.getParent().getId());
|
|
||||||
|
|
||||||
List<Map<String, Object>> childList = new ArrayList<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
|
map.put("id", permission.getId());
|
||||||
|
map.put("name", permission.getName());
|
||||||
|
map.put("desc", permission.getDescription());
|
||||||
|
map.put("url", permission.getUrl());
|
||||||
|
map.put("sort", permission.getSort());
|
||||||
|
map.put("parentId", permission.getParent() == null ? 0L : permission.getParent().getId());
|
||||||
|
map.put("children", new ArrayList<>());
|
||||||
|
|
||||||
if (!children.isEmpty()){
|
resultList.add(map);
|
||||||
for (Permission child : children) {
|
|
||||||
if (permissionList.contains(child)){
|
|
||||||
Map<String, Object> childMap = new HashMap<>();
|
|
||||||
childMap.put("id", child.getId());
|
|
||||||
childMap.put("name", child.getName());
|
|
||||||
childMap.put("desc", child.getDescription());
|
|
||||||
childMap.put("url", child.getUrl());
|
|
||||||
childMap.put("sort", child.getSort());
|
|
||||||
childMap.put("parentId", child.getParent() == null ? 0L : child.getParent().getId());
|
|
||||||
childList.add(childMap);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
map.put("children", childList);
|
|
||||||
|
|
||||||
resultList.add(map);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.success(resultList);
|
return Result.success(resultList);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue