From 7ff8c9dc54b8fafa4f91c5c15ed09c8567422ea7 Mon Sep 17 00:00:00 2001 From: cxt104926 <1049266034@qq.com> Date: Sun, 18 Apr 2021 23:56:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/stu/stusystem/config/MyShiroConfig.java | 1 + .../controller/system/StuClassController.java | 2 +- .../java/com/stu/stusystem/util/TreeModelUtil.java | 10 ++++++++-- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/stu/stusystem/config/MyShiroConfig.java b/src/main/java/com/stu/stusystem/config/MyShiroConfig.java index 0cc5a91..bd113f3 100644 --- a/src/main/java/com/stu/stusystem/config/MyShiroConfig.java +++ b/src/main/java/com/stu/stusystem/config/MyShiroConfig.java @@ -53,6 +53,7 @@ public class MyShiroConfig { filterChainDefinitionMap.put("/getVerify", "anon"); filterChainDefinitionMap.put("/register", "anon"); filterChainDefinitionMap.put("/favicon.ico", "anon"); + filterChainDefinitionMap.put("/stu/class/get/treeData", "anon"); filterChainDefinitionMap.put("/v2/api-docs/**", "anon"); filterChainDefinitionMap.put("/swagger-ui.html", "anon"); diff --git a/src/main/java/com/stu/stusystem/controller/system/StuClassController.java b/src/main/java/com/stu/stusystem/controller/system/StuClassController.java index edae44a..ce902d5 100644 --- a/src/main/java/com/stu/stusystem/controller/system/StuClassController.java +++ b/src/main/java/com/stu/stusystem/controller/system/StuClassController.java @@ -51,7 +51,7 @@ public class StuClassController { return ApiResult.success(); } - @ApiOperation("查询所有班级id、名字") + @ApiOperation("树形班级结构") @GetMapping("/get/treeData") public List getStuClassTreeData() { return this.stuClassService.getStuClassTreeData(); diff --git a/src/main/java/com/stu/stusystem/util/TreeModelUtil.java b/src/main/java/com/stu/stusystem/util/TreeModelUtil.java index f9dd256..8ce932d 100644 --- a/src/main/java/com/stu/stusystem/util/TreeModelUtil.java +++ b/src/main/java/com/stu/stusystem/util/TreeModelUtil.java @@ -47,7 +47,10 @@ public class TreeModelUtil { } // 查找child String id = (String) mapArr.get("id"); - mapArr.put("child", getTreeList(id, tm, pid)); + List treeList = getTreeList(id, tm, pid); + if (treeList.size() != 0) { + mapArr.put("child", treeList); + } list.add(mapArr); } } catch (IllegalAccessException e) { @@ -79,7 +82,10 @@ public class TreeModelUtil { } // 查找child String childId = (String) mapArr.get("id"); - mapArr.put("child", getTreeList(childId, treeModels, pid)); + List treeList = getTreeList(childId, treeModels, pid); + if (treeList.size() != 0) { + mapArr.put("child", treeList); + } lists.add(mapArr); } } catch (IllegalAccessException e) { -- GitLab