From 2f856ce55d2623dd15a11476994497bc80b395e2 Mon Sep 17 00:00:00 2001 From: smallchill Date: Thu, 23 Apr 2020 21:52:52 +0800 Subject: [PATCH] =?UTF-8?q?:zap:=20=E7=B3=BB=E7=BB=9F=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E3=80=81=E4=B8=9A=E5=8A=A1=E5=AD=97=E5=85=B8=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=A0=91=E5=BD=A2=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/controller/DictBizController.java | 4 ++-- .../system/controller/DictController.java | 4 ++-- .../springblade/system/service/IDictBizService.java | 5 +++-- .../org/springblade/system/service/IDictService.java | 6 ++++-- .../system/service/impl/DictBizServiceImpl.java | 12 +++++++++--- .../system/service/impl/DictServiceImpl.java | 12 +++++++++--- 6 files changed, 29 insertions(+), 14 deletions(-) diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictBizController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictBizController.java index bd487fdd..98979c25 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictBizController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictBizController.java @@ -102,8 +102,8 @@ public class DictBizController extends BladeController { }) @ApiOperationSupport(order = 4) @ApiOperation(value = "列表", notes = "传入dict") - public R> childList(@ApiIgnore @RequestParam Map dict, @RequestParam(required = false, defaultValue = "-1") Long parentId, Query query) { - return R.data(dictService.childList(dict, parentId, query)); + public R> childList(@ApiIgnore @RequestParam Map dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) { + return R.data(dictService.childList(dict, parentId)); } /** diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java index 03a51872..d6fc0cf5 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java @@ -104,8 +104,8 @@ public class DictController extends BladeController { }) @ApiOperationSupport(order = 4) @ApiOperation(value = "列表", notes = "传入dict") - public R> childList(@ApiIgnore @RequestParam Map dict, @RequestParam(required = false, defaultValue = "-1") Long parentId, Query query) { - return R.data(dictService.childList(dict, parentId, query)); + public R> childList(@ApiIgnore @RequestParam Map dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) { + return R.data(dictService.childList(dict, parentId)); } /** diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictBizService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictBizService.java index 6788910f..e254f400 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictBizService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictBizService.java @@ -82,6 +82,7 @@ public interface IDictBizService extends IService { /** * 顶级列表 + * * @param dict * @param query * @return @@ -90,11 +91,11 @@ public interface IDictBizService extends IService { /** * 子列表 + * * @param dict * @param parentId - * @param query * @return */ - IPage childList(Map dict, Long parentId, Query query); + List childList(Map dict, Long parentId); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java index 5de99109..28d3a33d 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java @@ -74,6 +74,7 @@ public interface IDictService extends IService { /** * 新增或修改 + * * @param dict * @return */ @@ -89,6 +90,7 @@ public interface IDictService extends IService { /** * 顶级列表 + * * @param dict * @param query * @return @@ -97,11 +99,11 @@ public interface IDictService extends IService { /** * 子列表 + * * @param dict * @param parentId - * @param query * @return */ - IPage childList(Map dict, Long parentId, Query query); + List childList(Map dict, Long parentId); } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java index de303d6d..9830ebd1 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java @@ -29,6 +29,7 @@ import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; +import org.springblade.system.cache.DictBizCache; import org.springblade.system.entity.DictBiz; import org.springblade.system.mapper.DictBizMapper; import org.springblade.system.service.IDictBizService; @@ -36,6 +37,7 @@ import org.springblade.system.vo.DictBizVO; import org.springblade.system.wrapper.DictBizWrapper; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -100,9 +102,13 @@ public class DictBizServiceImpl extends ServiceImpl impl } @Override - public IPage childList(Map dict, Long parentId, Query query) { + public List childList(Map dict, Long parentId) { + if (parentId < 0) { + return new ArrayList<>(); + } dict.remove("parentId"); - IPage page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, DictBiz.class).lambda().eq(DictBiz::getParentId, parentId).orderByAsc(DictBiz::getSort)); - return DictBizWrapper.build().pageVO(page); + DictBiz parentDict = DictBizCache.getById(parentId); + List list = this.list(Condition.getQueryWrapper(dict, DictBiz.class).lambda().ne(DictBiz::getId, parentId).eq(DictBiz::getCode, parentDict.getCode()).orderByAsc(DictBiz::getSort)); + return DictBizWrapper.build().listNodeVO(list); } } diff --git a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java index be91beff..be982f5b 100644 --- a/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java +++ b/blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java @@ -29,6 +29,7 @@ import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringPool; +import org.springblade.system.cache.DictCache; import org.springblade.system.entity.Dict; import org.springblade.system.mapper.DictMapper; import org.springblade.system.service.IDictService; @@ -36,6 +37,7 @@ import org.springblade.system.vo.DictVO; import org.springblade.system.wrapper.DictWrapper; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -106,9 +108,13 @@ public class DictServiceImpl extends ServiceImpl implements ID } @Override - public IPage childList(Map dict, Long parentId, Query query) { + public List childList(Map dict, Long parentId) { + if (parentId < 0) { + return new ArrayList<>(); + } dict.remove("parentId"); - IPage page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, parentId).orderByAsc(Dict::getSort)); - return DictWrapper.build().pageVO(page); + Dict parentDict = DictCache.getById(parentId); + List list = this.list(Condition.getQueryWrapper(dict, Dict.class).lambda().ne(Dict::getId, parentId).eq(Dict::getCode, parentDict.getCode()).orderByAsc(Dict::getSort)); + return DictWrapper.build().listNodeVO(list); } }