From 753e7083baeebaea975939ce205d703aef2259ac Mon Sep 17 00:00:00 2001 From: qmstyle Date: Thu, 10 Apr 2025 17:45:22 +0800 Subject: [PATCH] =?UTF-8?q?2025=E5=B9=B44=E6=9C=8810=E6=97=A516:25:46?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../exam/controller/RoleController.java | 76 +++++++++++-------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/main/java/com/zhangmeng/online/exam/controller/RoleController.java b/src/main/java/com/zhangmeng/online/exam/controller/RoleController.java index 9021756..8a30027 100644 --- a/src/main/java/com/zhangmeng/online/exam/controller/RoleController.java +++ b/src/main/java/com/zhangmeng/online/exam/controller/RoleController.java @@ -86,11 +86,11 @@ public class RoleController { String desc = params.get("desc").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(); - }else { + } else { role = new Role(); } @@ -130,38 +130,50 @@ public class RoleController { List> resultList = new ArrayList<>(); for (Permission permission : permissionList) { - if (permission.getParent() == null){ - List children = permission.getChildren(); +// if (permission.getParent() == null){ +// List children = permission.getChildren(); +// +// Map 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> childList = new ArrayList<>(); +// +// if (!children.isEmpty()){ +// for (Permission child : children) { +// if (permissionList.contains(child)){ +// Map 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 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> childList = new ArrayList<>(); + Map 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()){ - for (Permission child : children) { - if (permissionList.contains(child)){ - Map 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); - } + resultList.add(map); } return Result.success(resultList);