feat: 零部件回显接口返回值变更
This commit is contained in:
+2
-2
@@ -47,9 +47,9 @@ public class LawsPartNameController {
|
||||
@AutoLog(value = "企业标准-零部件树选中回显")
|
||||
@ApiOperation(value = "企业标准-零部件树选中回显", notes = "企业标准-零部件树选中回显")
|
||||
@GetMapping("/echo")
|
||||
public Result<TreePage<PartName>> queryEcho(@RequestParam(name = "selectNodeCodes", required = false, defaultValue = "")
|
||||
public Result<List<PartName>> queryEcho(@RequestParam(name = "selectNodeCodes", required = false, defaultValue = "")
|
||||
@ApiParam("选中的节点名称") String selectNodeCodes) {
|
||||
TreePage<PartName> list = partNameService.queryEcho(selectNodeCodes);
|
||||
List<PartName> list = partNameService.queryEcho(selectNodeCodes);
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
|
||||
+1
-3
@@ -1,7 +1,5 @@
|
||||
package com.jero.modules.laws.standard.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
|
||||
import com.jero.modules.laws.standard.entity.PartName;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.laws.standard.entity.TreePage;
|
||||
@@ -31,5 +29,5 @@ public interface PartNameService extends IService<PartName> {
|
||||
* @param selectNodeCodes 选中的节点code
|
||||
* @return 零部件树
|
||||
*/
|
||||
TreePage<PartName> queryEcho(String selectNodeCodes);
|
||||
List<PartName> queryEcho(String selectNodeCodes);
|
||||
}
|
||||
|
||||
+4
-35
@@ -77,43 +77,12 @@ public class PartNameServiceImpl extends ServiceImpl<PartNameMapper, PartName>
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreePage<PartName> queryEcho(String selectNodeCodes) {
|
||||
int pageNo = 1;
|
||||
int pageSize = 1000;
|
||||
public List<PartName> queryEcho(String selectNodeCodes) {
|
||||
List<String> codeList = StrUtil.split(selectNodeCodes, ',');
|
||||
LambdaQueryWrapper<PartName> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PartName::getDelFlag, YesOrNoEnum.NO.getValue())
|
||||
.in(PartName::getCode, selectNodeCodes.split(","));
|
||||
List<PartName> allNodes = partNameMapper.selectList(queryWrapper);
|
||||
|
||||
// 将所有节点转换为映射,以便快速查找
|
||||
Map<String, PartName> nodeMap = allNodes.stream()
|
||||
.collect(Collectors.toMap(PartName::getId, Function.identity()));
|
||||
|
||||
// 构建树形结构
|
||||
List<PartName> topLevelNodes = new ArrayList<>();
|
||||
allNodes.forEach(node -> {
|
||||
if (node.getParentId() == null) {
|
||||
topLevelNodes.add(node);
|
||||
} else {
|
||||
PartName parentNode = nodeMap.get(node.getParentId());
|
||||
if (parentNode != null) {
|
||||
if (parentNode.getChildPartNameList() == null) {
|
||||
parentNode.setChildPartNameList(new ArrayList<>());
|
||||
}
|
||||
parentNode.getChildPartNameList().add(node);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// 实现分页逻辑
|
||||
int start = 0;
|
||||
int end = Math.min(start + pageSize, topLevelNodes.size());
|
||||
List<PartName> pageData = topLevelNodes.subList(start, end);
|
||||
|
||||
// 封装分页信息
|
||||
TreePage<PartName> result = new TreePage<>();
|
||||
result.setRecords(pageData);
|
||||
return result;
|
||||
.in(PartName::getCode, codeList);
|
||||
return partNameMapper.selectList(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user