feat: 通用树形接口取消分页
This commit is contained in:
+2
-4
@@ -2283,7 +2283,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
private String getTreeFatherChild(String tableName, String key, String value, String dicId) {
|
||||
LambdaQueryWrapper<SysDictItem> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysDictItem::getDictId, dicId);
|
||||
wrapper.eq(SysDictItem::getItemValue, value);
|
||||
wrapper.eq(SysDictItem::getId, value);
|
||||
SysDictItem targetNode = sysDictItemService.getOne(wrapper);
|
||||
List<SysDictItem> resultNodeList = new ArrayList<>();
|
||||
// 获取所有数据
|
||||
@@ -2321,7 +2321,7 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
private String getTreeChild(String tableName, String key, String value, String dicId) {
|
||||
LambdaQueryWrapper<SysDictItem> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(SysDictItem::getDictId, dicId);
|
||||
wrapper.eq(SysDictItem::getItemValue, value);
|
||||
wrapper.eq(SysDictItem::getId, value);
|
||||
SysDictItem targetNode = sysDictItemService.getOne(wrapper);
|
||||
// 获取整颗零部件树
|
||||
wrapper.clear();
|
||||
@@ -2491,11 +2491,9 @@ public class LawsCommonServiceImpl implements ILawsCommonService {
|
||||
}else if (FieldShowTypeEnum.TREE_FATHER_CHILD.getValue().equals(fieldShowType)) {
|
||||
String sql = getTreeFatherChild(tableName, key, value, lawsTag.getDictId());
|
||||
selectCondition.append(sql);
|
||||
parameterMap.remove(key);
|
||||
} else if (FieldShowTypeEnum.TREE_CHILD.getValue().equals(fieldShowType)) {
|
||||
String sql = getTreeChild(tableName, key, value, lawsTag.getDictId());
|
||||
selectCondition.append(sql);
|
||||
parameterMap.remove(key);
|
||||
}
|
||||
// 处理其他类型
|
||||
}
|
||||
|
||||
+3
-6
@@ -2,7 +2,6 @@ package com.jero.modules.laws.standard.controller;
|
||||
|
||||
import com.jero.common.api.vo.Result;
|
||||
import com.jero.common.aspect.annotation.AutoLog;
|
||||
import com.jero.modules.laws.standard.entity.TreePage;
|
||||
import com.jero.modules.laws.standard.service.DictTreeService;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -31,12 +30,10 @@ public class LawsDictTreeController {
|
||||
@AutoLog(value = "树形结构-获取一级树")
|
||||
@ApiOperation(value = "树形结构-获取一级树", notes = "树形结构-获取一级树")
|
||||
@GetMapping("/page")
|
||||
public Result<TreePage<SysDictItem>> queryTreeList(
|
||||
public Result<List<SysDictItem>> queryTreeList(
|
||||
@RequestParam(name = "nodeName", required = false, defaultValue = "") @ApiParam("一级节点名称") String nodeName,
|
||||
@RequestParam("dictId") @ApiParam("字典编码") String dictId,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") @ApiParam("页码") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") @ApiParam("页面大小") Integer pageSize) {
|
||||
TreePage<SysDictItem> list = dictTreeService.queryTreeList(nodeName, dictId, pageNo, pageSize);
|
||||
@RequestParam("dictId") @ApiParam("字典编码") String dictId) {
|
||||
List<SysDictItem> list = dictTreeService.queryTreeList(nodeName, dictId);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
|
||||
+5
-9
@@ -1,9 +1,6 @@
|
||||
package com.jero.modules.laws.standard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.jero.modules.laws.standard.entity.TreePage;
|
||||
import com.jero.modules.system.entity.SysDictItem;
|
||||
import com.jero.modules.system.service.ISysDictItemService;
|
||||
import com.jero.modules.system.service.ISysDictService;
|
||||
@@ -23,28 +20,27 @@ public class DictTreeService {
|
||||
@Resource
|
||||
private ISysDictItemService dictItemService;
|
||||
|
||||
public TreePage<SysDictItem> queryTreeList(String nodeName, String dictId, Integer pageNo, Integer pageSize) {
|
||||
public List<SysDictItem> queryTreeList(String nodeName, String dictId) {
|
||||
LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.eq(SysDictItem::getParentId, "0");
|
||||
if (nodeName != null && !nodeName.isEmpty()) {
|
||||
queryWrapper.like(SysDictItem::getItemText, nodeName);
|
||||
}
|
||||
Page<SysDictItem> page = new Page<>(pageNo, pageSize);
|
||||
IPage<SysDictItem> pageList = dictItemService.page(page, queryWrapper);
|
||||
List<SysDictItem> list = dictItemService.list(queryWrapper);
|
||||
|
||||
List<String> dictItemIds = pageList.getRecords().stream().map(SysDictItem::getId).collect(Collectors.toList());
|
||||
List<String> dictItemIds = list.stream().map(SysDictItem::getId).collect(Collectors.toList());
|
||||
// 判断有没有子级
|
||||
queryWrapper.clear();
|
||||
queryWrapper.eq(SysDictItem::getDictId, dictId);
|
||||
queryWrapper.in(SysDictItem::getParentId, dictItemIds);
|
||||
List<SysDictItem> childList = dictItemService.list(queryWrapper);
|
||||
pageList.getRecords().forEach(item -> {
|
||||
list.forEach(item -> {
|
||||
if (childList.stream().anyMatch(child -> child.getParentId().equals(item.getId()))) {
|
||||
item.setHasChild(true);
|
||||
}
|
||||
});
|
||||
return new TreePage<>(pageList.getRecords(), pageList.getTotal(), pageList.getSize(), pageList.getCurrent());
|
||||
return list;
|
||||
}
|
||||
|
||||
public List<SysDictItem> queryEcho(String selectNodeCodes, String dictId) {
|
||||
|
||||
Reference in New Issue
Block a user