update 标签管理-树形查询
This commit is contained in:
+8
-8
@@ -98,12 +98,14 @@ public class SysDictItemController {
|
||||
List<SysDictItem> sysDictItems = sysDictItemService.list(queryWrapper);
|
||||
//当查询结果中有数据的父级不存在时,赋值父级id为"0"
|
||||
List<String> idList = sysDictItems.stream().map(SysDictItem::getId).collect(Collectors.toList());
|
||||
//保存数据中的父级id
|
||||
Map<String, String> map1 = CollStreamUtil.toMap(sysDictItems, SysDictItem::getId, SysDictItem::getParentId);
|
||||
idList.add("0");
|
||||
//赋值pId
|
||||
sysDictItems.forEach(i ->{
|
||||
if (!idList.contains(i.getParentId())) {
|
||||
i.setParentId("0");
|
||||
String parentId = i.getParentId();
|
||||
if (idList.contains(parentId)) {
|
||||
i.setPId(parentId);
|
||||
}else {
|
||||
i.setPId("0");
|
||||
}
|
||||
});
|
||||
//配置
|
||||
@@ -119,16 +121,14 @@ public class SysDictItemController {
|
||||
(treeNode, tree) -> {
|
||||
String id = treeNode.getId();
|
||||
tree.setId(id);
|
||||
tree.setParentId(treeNode.getParentId());
|
||||
tree.setParentId(treeNode.getPId());
|
||||
tree.setWeight(treeNode.getSortOrder());
|
||||
tree.setName(treeNode.getItemText());
|
||||
// 扩展属性 ...
|
||||
Map<String, Object> map = BeanUtil.beanToMap(treeNode,"dictId","itemText","itemValue","enName","description","sortOrder","status");
|
||||
Map<String, Object> map = BeanUtil.beanToMap(treeNode,"dictId","parentId","itemText","itemValue","enName","description","sortOrder","status");
|
||||
for (String s : map.keySet()) {
|
||||
tree.putExtra(s, map.get(s));
|
||||
}
|
||||
String parentId = map1.get(id);
|
||||
tree.putExtra("parentId",parentId);
|
||||
});
|
||||
|
||||
JSONArray jsonArray = JSONArray.parseArray(JSON.toJSONString(treeNodes,SerializerFeature.WriteMapNullValue));
|
||||
|
||||
@@ -43,6 +43,11 @@ public class SysDictItem implements Serializable {
|
||||
* 父级id
|
||||
*/
|
||||
private String parentId;
|
||||
/**
|
||||
* 父级id(树形结构使用)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String pId;
|
||||
|
||||
/**
|
||||
* 字典项文本
|
||||
|
||||
Reference in New Issue
Block a user