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 30a1b98f..d81bef82 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 @@ -19,7 +19,6 @@ package org.springblade.system.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.*; import lombok.AllArgsConstructor; -import org.springblade.common.constant.CommonConstant; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -89,8 +88,7 @@ public class DictBizController extends BladeController { @ApiOperationSupport(order = 3) @ApiOperation(value = "列表", notes = "传入dict") public R> parentList(@ApiIgnore @RequestParam Map dict, Query query) { - IPage page = dictService.page(Condition.getPage(query), Condition.getQueryWrapper(dict, DictBiz.class).lambda().eq(DictBiz::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(DictBiz::getSort)); - return R.data(DictBizWrapper.build().pageVO(page)); + return R.data(dictService.parentList(dict, query)); } /** @@ -105,9 +103,7 @@ 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) { - dict.remove("parentId"); - IPage page = dictService.page(Condition.getPage(query), Condition.getQueryWrapper(dict, DictBiz.class).lambda().eq(DictBiz::getParentId, parentId).orderByAsc(DictBiz::getSort)); - return R.data(DictBizWrapper.build().pageVO(page)); + return R.data(dictService.childList(dict, parentId, query)); } /** 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 c73879b3..8274a8c9 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 @@ -19,7 +19,6 @@ package org.springblade.system.controller; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.*; import lombok.AllArgsConstructor; -import org.springblade.common.constant.CommonConstant; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; @@ -75,7 +74,6 @@ public class DictController extends BladeController { @ApiOperationSupport(order = 2) @ApiOperation(value = "列表", notes = "传入dict") public R> list(@ApiIgnore @RequestParam Map dict) { - @SuppressWarnings("unchecked") List list = dictService.list(Condition.getQueryWrapper(dict, Dict.class).lambda().orderByAsc(Dict::getSort)); DictWrapper dictWrapper = new DictWrapper(); return R.data(dictWrapper.listNodeVO(list)); @@ -92,8 +90,7 @@ public class DictController extends BladeController { @ApiOperationSupport(order = 3) @ApiOperation(value = "列表", notes = "传入dict") public R> parentList(@ApiIgnore @RequestParam Map dict, Query query) { - IPage page = dictService.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(Dict::getSort)); - return R.data(DictWrapper.build().pageVO(page)); + return R.data(dictService.parentList(dict, query)); } /** @@ -108,9 +105,7 @@ 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) { - dict.remove("parentId"); - IPage page = dictService.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, parentId).orderByAsc(Dict::getSort)); - return R.data(DictWrapper.build().pageVO(page)); + return R.data(dictService.childList(dict, parentId, query)); } /** 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 b6793af6..90413afc 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 @@ -17,11 +17,14 @@ package org.springblade.system.service; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import org.springblade.core.mp.support.Query; import org.springblade.system.entity.DictBiz; import org.springblade.system.vo.DictBizVO; import java.util.List; +import java.util.Map; /** * 服务类 @@ -77,4 +80,21 @@ public interface IDictBizService extends IService { */ boolean removeDict(String ids); + /** + * 顶级列表 + * @param dict + * @param query + * @return + */ + IPage parentList(Map dict, Query query); + + /** + * 子列表 + * @param dict + * @param parentId + * @param query + * @return + */ + IPage childList(Map dict, Long parentId, Query query); + } 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 40ae1dce..2772ada7 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 @@ -18,10 +18,12 @@ package org.springblade.system.service; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import org.springblade.core.mp.support.Query; import org.springblade.system.entity.Dict; import org.springblade.system.vo.DictVO; import java.util.List; +import java.util.Map; /** * 服务类 @@ -85,4 +87,21 @@ public interface IDictService extends IService { */ boolean removeDict(String ids); + /** + * 顶级列表 + * @param dict + * @param query + * @return + */ + IPage parentList(Map dict, Query query); + + /** + * 子列表 + * @param dict + * @param parentId + * @param query + * @return + */ + IPage childList(Map dict, Long parentId, Query query); + } 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 bdc50892..15e56388 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 @@ -17,9 +17,13 @@ package org.springblade.system.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.exceptions.ApiException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springblade.common.constant.CommonConstant; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; @@ -28,10 +32,12 @@ import org.springblade.system.entity.DictBiz; import org.springblade.system.mapper.DictBizMapper; import org.springblade.system.service.IDictBizService; import org.springblade.system.vo.DictBizVO; +import org.springblade.system.wrapper.DictBizWrapper; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; @@ -86,4 +92,17 @@ public class DictBizServiceImpl extends ServiceImpl impl } return removeByIds(Func.toLongList(ids)); } + + @Override + public IPage parentList(Map dict, Query query) { + IPage page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, DictBiz.class).lambda().eq(DictBiz::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(DictBiz::getSort)); + return DictBizWrapper.build().pageVO(page); + } + + @Override + public IPage childList(Map dict, Long parentId, Query query) { + 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); + } } 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 cf37f0b8..1b9a6ac3 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 @@ -21,6 +21,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.exceptions.ApiException; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springblade.common.constant.CommonConstant; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; import org.springblade.core.tool.constant.BladeConstant; import org.springblade.core.tool.node.ForestNodeMerger; import org.springblade.core.tool.utils.Func; @@ -29,10 +32,12 @@ import org.springblade.system.entity.Dict; import org.springblade.system.mapper.DictMapper; import org.springblade.system.service.IDictService; import org.springblade.system.vo.DictVO; +import org.springblade.system.wrapper.DictWrapper; import org.springframework.cache.annotation.CacheEvict; import org.springframework.stereotype.Service; import java.util.List; +import java.util.Map; import static org.springblade.core.cache.constant.CacheConstant.DICT_CACHE; @@ -93,4 +98,17 @@ public class DictServiceImpl extends ServiceImpl implements ID } return removeByIds(Func.toLongList(ids)); } + + @Override + public IPage parentList(Map dict, Query query) { + IPage page = this.page(Condition.getPage(query), Condition.getQueryWrapper(dict, Dict.class).lambda().eq(Dict::getParentId, CommonConstant.TOP_PARENT_ID).orderByAsc(Dict::getSort)); + return DictWrapper.build().pageVO(page); + } + + @Override + public IPage childList(Map dict, Long parentId, Query query) { + 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); + } }