Browse Source

系统字典、业务字典增加树形结构

test
smallchill 5 years ago
parent
commit
2f856ce55d
  1. 4
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DictBizController.java
  2. 4
      blade-service/blade-system/src/main/java/org/springblade/system/controller/DictController.java
  3. 5
      blade-service/blade-system/src/main/java/org/springblade/system/service/IDictBizService.java
  4. 6
      blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java
  5. 12
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictBizServiceImpl.java
  6. 12
      blade-service/blade-system/src/main/java/org/springblade/system/service/impl/DictServiceImpl.java

4
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<IPage<DictBizVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId, Query query) {
return R.data(dictService.childList(dict, parentId, query));
public R<List<DictBizVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) {
return R.data(dictService.childList(dict, parentId));
}
/**

4
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<IPage<DictVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId, Query query) {
return R.data(dictService.childList(dict, parentId, query));
public R<List<DictVO>> childList(@ApiIgnore @RequestParam Map<String, Object> dict, @RequestParam(required = false, defaultValue = "-1") Long parentId) {
return R.data(dictService.childList(dict, parentId));
}
/**

5
blade-service/blade-system/src/main/java/org/springblade/system/service/IDictBizService.java

@ -82,6 +82,7 @@ public interface IDictBizService extends IService<DictBiz> {
/**
* 顶级列表
*
* @param dict
* @param query
* @return
@ -90,11 +91,11 @@ public interface IDictBizService extends IService<DictBiz> {
/**
* 子列表
*
* @param dict
* @param parentId
* @param query
* @return
*/
IPage<DictBizVO> childList(Map<String, Object> dict, Long parentId, Query query);
List<DictBizVO> childList(Map<String, Object> dict, Long parentId);
}

6
blade-service/blade-system/src/main/java/org/springblade/system/service/IDictService.java

@ -74,6 +74,7 @@ public interface IDictService extends IService<Dict> {
/**
* 新增或修改
*
* @param dict
* @return
*/
@ -89,6 +90,7 @@ public interface IDictService extends IService<Dict> {
/**
* 顶级列表
*
* @param dict
* @param query
* @return
@ -97,11 +99,11 @@ public interface IDictService extends IService<Dict> {
/**
* 子列表
*
* @param dict
* @param parentId
* @param query
* @return
*/
IPage<DictVO> childList(Map<String, Object> dict, Long parentId, Query query);
List<DictVO> childList(Map<String, Object> dict, Long parentId);
}

12
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<DictBizMapper, DictBiz> impl
}
@Override
public IPage<DictBizVO> childList(Map<String, Object> dict, Long parentId, Query query) {
public List<DictBizVO> childList(Map<String, Object> dict, Long parentId) {
if (parentId < 0) {
return new ArrayList<>();
}
dict.remove("parentId");
IPage<DictBiz> 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<DictBiz> 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);
}
}

12
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<DictMapper, Dict> implements ID
}
@Override
public IPage<DictVO> childList(Map<String, Object> dict, Long parentId, Query query) {
public List<DictVO> childList(Map<String, Object> dict, Long parentId) {
if (parentId < 0) {
return new ArrayList<>();
}
dict.remove("parentId");
IPage<Dict> 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<Dict> 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);
}
}

Loading…
Cancel
Save