feat: 体系树维护我的收藏节点

This commit is contained in:
2023-09-13 10:13:52 +08:00
parent bbf328c550
commit 3f3c431317
2 changed files with 28 additions and 8 deletions
@@ -0,0 +1,14 @@
package com.jero.modules.laws.common.constant;
/**
* @author: Mzaxd
* @Date: 2023/9/13 9:51
*/
public class TreeNodeConstants {
// 根节点 不能删改
public static final Integer NODE_TYPE_ROOT = 1;
// 根节点 不能增删改
public static final Integer NODE_TYPE_MY_COLLECT = 0;
}
@@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.jero.common.constant.CommonConstant;
import com.jero.common.constant.FillRuleConstant;
import com.jero.common.util.FillRuleUtil;
import com.jero.modules.laws.common.constant.TreeNodeConstants;
import com.jero.modules.laws.enterprise.entity.vo.LawsTreeNodeModel;
import com.jero.modules.laws.enterprise.util.FindsTreeNodeChildrenUtil;
import com.jero.modules.laws.standard.entity.LawsNodeRelation;
@@ -66,14 +67,19 @@ public class LawsTreeNodeServiceImpl extends ServiceImpl<LawsTreeNodeMapper, Law
// 调用wrapTreeDataToTreeList方法生成树状数据
List<LawsTreeNodeModel> lawsTreeNodeModels = FindsTreeNodeChildrenUtil.wrapTreeDataToTreeList(lawsTreeNodes);
// 添加我的收藏节点
LawsTreeNodeModel myCollect = new LawsTreeNodeModel();
myCollect.setKey("myCollect");
myCollect.setValue("myCollect");
myCollect.setNodeName("我的收藏");
myCollect.setTitle("我的收藏");
// 不为空是选择框,为空是左侧树
if (StringUtils.isBlank(option)) {
lawsTreeNodeModels.add(myCollect);
if ("我的收藏".contains(nodeName) && StringUtils.isBlank(option)) {
LawsTreeNodeModel myCollect = new LawsTreeNodeModel();
myCollect.setKey("myCollect");
myCollect.setValue("myCollect");
myCollect.setTitle("我的收藏");
myCollect.setNodeType(TreeNodeConstants.NODE_TYPE_MY_COLLECT);
LawsTreeNodeModel rootNode = lawsTreeNodeModels.get(0);
List<LawsTreeNodeModel> children = rootNode.getChildren();
if (children == null) {
children = new ArrayList<>();
}
children.add(myCollect);
rootNode.setChildren(children);
}
return lawsTreeNodeModels;
}