From 0fce735053bdfcf00e53e4301d4519fd9369b2df Mon Sep 17 00:00:00 2001 From: Liu Rui Date: Wed, 23 Oct 2024 13:50:38 +0800 Subject: [PATCH] =?UTF-8?q?fix-DictCategoryController-=E4=BF=AE=E6=AD=A3tr?= =?UTF-8?q?ee=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96=E5=88=B0=E7=9A=84?= =?UTF-8?q?=E5=AD=90=E5=AD=99=E6=95=B0=E6=8D=AE=E6=B2=A1=E6=9C=89value?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ximatai/muyun/test/plaform/TestDictController.java | 9 ++++----- .../ximatai/muyun/ability/curd/std/IUpdateAbility.java | 2 +- .../src/main/java/net/ximatai/muyun/model/TreeNode.java | 6 +++--- .../platform/controller/DictCategoryController.java | 2 +- .../muyun/platform/controller/RuntimeController.java | 2 +- .../net/ximatai/muyun/platform/model/DictTreeNode.java | 7 +++++++ 6 files changed, 17 insertions(+), 11 deletions(-) diff --git a/muyun-boot/src/test/java/net/ximatai/muyun/test/plaform/TestDictController.java b/muyun-boot/src/test/java/net/ximatai/muyun/test/plaform/TestDictController.java index 6ee4c0e8..409d7bed 100644 --- a/muyun-boot/src/test/java/net/ximatai/muyun/test/plaform/TestDictController.java +++ b/muyun-boot/src/test/java/net/ximatai/muyun/test/plaform/TestDictController.java @@ -185,7 +185,7 @@ void testDictCategoryAdd() { .extract() .asString(); - given() + List responsex = given() .header("userID", config.superUserId()) .get("%s/dict/tree/%s".formatted(base, "root1")) .then() @@ -194,10 +194,9 @@ void testDictCategoryAdd() { .as(new TypeRef<>() { }); -// assertEquals(response.size(), 3); -// node = response.get(0); -// assertEquals(node.getChildren().size(), 1); -// assertNotNull(node.getValue()); + assertEquals(responsex.size(), 3); + Map nodex = ((List) responsex.get(0).get("children")).get(0); + assertNotNull(nodex.get("value")); List response2 = given() .header("userID", config.superUserId()) diff --git a/muyun-core/src/main/java/net/ximatai/muyun/ability/curd/std/IUpdateAbility.java b/muyun-core/src/main/java/net/ximatai/muyun/ability/curd/std/IUpdateAbility.java index 189e0ae3..221c2382 100644 --- a/muyun-core/src/main/java/net/ximatai/muyun/ability/curd/std/IUpdateAbility.java +++ b/muyun-core/src/main/java/net/ximatai/muyun/ability/curd/std/IUpdateAbility.java @@ -87,7 +87,7 @@ default Integer update(@PathParam("id") String id, Map body) { return result; } - private boolean isIdInTree(List tree, String id) { + private boolean isIdInTree(List tree, String id) { for (TreeNode node : tree) { if (node.getId().equals(id)) { return true; diff --git a/muyun-core/src/main/java/net/ximatai/muyun/model/TreeNode.java b/muyun-core/src/main/java/net/ximatai/muyun/model/TreeNode.java index 075ce7c8..5c2cdc8a 100644 --- a/muyun-core/src/main/java/net/ximatai/muyun/model/TreeNode.java +++ b/muyun-core/src/main/java/net/ximatai/muyun/model/TreeNode.java @@ -14,7 +14,7 @@ public class TreeNode { @Schema(description = "数据内容") private Map data; @Schema(description = "子节点") - private List children; + private List children; public TreeNode() { } @@ -31,7 +31,7 @@ public Map getData() { return data; } - public List getChildren() { + public List getChildren() { return children; } @@ -51,7 +51,7 @@ public TreeNode setData(Map data) { } public TreeNode setChildren(List children) { - this.children = (List) children; + this.children = children; return this; } diff --git a/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/DictCategoryController.java b/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/DictCategoryController.java index edbf5e34..b25c211d 100644 --- a/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/DictCategoryController.java +++ b/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/DictCategoryController.java @@ -67,7 +67,7 @@ private List nodeToDictNode(List list) { return list.stream().map(it -> { DictTreeNode node = DictTreeNode.from(it) .setValue(it.getData().get("v_value").toString()); - List children = node.getChildren(); + List children = node.getChildren(); if (children != null && !children.isEmpty()) { node.setChildren(nodeToDictNode(children)); } diff --git a/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/RuntimeController.java b/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/RuntimeController.java index e46538a8..d4a96a51 100644 --- a/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/RuntimeController.java +++ b/muyun-platform/src/main/java/net/ximatai/muyun/platform/controller/RuntimeController.java @@ -107,7 +107,7 @@ private List filterMenuByAuth(List list) { return filterMenuByAuth(list, authorizedResources); } - private List filterMenuByAuth(List list, Map> resources) { + private List filterMenuByAuth(List list, Map> resources) { List result = new ArrayList<>(); for (TreeNode node : list) { Map data = node.getData(); diff --git a/muyun-platform/src/main/java/net/ximatai/muyun/platform/model/DictTreeNode.java b/muyun-platform/src/main/java/net/ximatai/muyun/platform/model/DictTreeNode.java index 3f7037ea..3cdf0bca 100644 --- a/muyun-platform/src/main/java/net/ximatai/muyun/platform/model/DictTreeNode.java +++ b/muyun-platform/src/main/java/net/ximatai/muyun/platform/model/DictTreeNode.java @@ -3,6 +3,8 @@ import net.ximatai.muyun.model.TreeNode; import org.eclipse.microprofile.openapi.annotations.media.Schema; +import java.util.List; + public class DictTreeNode extends TreeNode { @Schema(description = "字典值") private String value; @@ -23,4 +25,9 @@ public DictTreeNode setValue(String value) { this.value = value; return this; } + + @Override + public List getChildren() { + return (List) super.getChildren(); + } }