REQ-3540: try to repair tree

This commit is contained in:
yanglin 2025-03-21 09:33:21 +08:00
parent f17e00844f
commit 76dcf5f500
3 changed files with 11 additions and 5 deletions

View File

@ -3,7 +3,6 @@ package cn.axzo.nanopart.doc.file;
import java.util.List;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@ -11,12 +10,13 @@ import org.springframework.web.bind.annotation.RestController;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import cn.axzo.maokai.api.vo.response.tree.Node;
import cn.axzo.maokai.api.vo.response.tree.TreeBuilder;
import cn.axzo.nanopart.doc.entity.IndexNode;
import cn.axzo.nanopart.doc.file.index.IndexQueryService;
import cn.axzo.nanopart.doc.integration.OssClient;
import cn.axzo.nanopart.doc.utils.IndexNodeTreeUtils;
import lombok.RequiredArgsConstructor;
/**
@ -41,7 +41,7 @@ public class DocPrivateController {
SimplePropertyPreFilter filter = new SimplePropertyPreFilter();
filter.getExcludes().add("parent");
filter.getExcludes().add("treeRoot");
Node node = TreeBuilder.build(indexNodes, true).getChildren().get(0);
Node node = IndexNodeTreeUtils.build(indexNodes).getChildren().get(0);
return JSON.parseObject(JSON.toJSONString(node, filter), Feature.DisableCircularReferenceDetect);
}

View File

@ -14,7 +14,6 @@ import org.springframework.transaction.support.TransactionTemplate;
import cn.axzo.maokai.api.util.Ref;
import cn.axzo.maokai.api.vo.response.tree.RootNode;
import cn.axzo.maokai.api.vo.response.tree.TreeBuilder;
import cn.axzo.maokai.api.vo.response.tree.TreeUtils;
import cn.axzo.nanopart.doc.api.domain.NodeCreate;
import cn.axzo.nanopart.doc.api.domain.OssFile;
@ -33,6 +32,7 @@ import cn.axzo.nanopart.doc.file.index.domain.NameUsedException;
import cn.axzo.nanopart.doc.file.mq.FileBroadcaster;
import cn.axzo.nanopart.doc.integration.OssClient;
import cn.axzo.nanopart.doc.utils.BizTransactional;
import cn.axzo.nanopart.doc.utils.IndexNodeTreeUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
@ -185,7 +185,7 @@ public class IndexManager {
if (docProps.isLockSubtreeWhenMove())
indexSupport.lockSubtree(srcNode);
List<IndexNode> subtreeNodes = indexSupport.collectValidSubtreeAsValueRoot(srcNode);
RootNode<IndexNode> moveRoot = TreeBuilder.build(subtreeNodes, true);
RootNode<IndexNode> moveRoot = IndexNodeTreeUtils.build(subtreeNodes);
docLogDao.log("indexNode:asyncMove", srcCode, "srcCode", srcCode, "destParentCode", destParentCode);
return connectNodes(moveRoot, destParentNode);
}));

View File

@ -10,7 +10,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import cn.axzo.maokai.api.vo.response.tree.RootNode;
import cn.axzo.maokai.api.vo.response.tree.TreeBuilder;
import cn.axzo.maokai.api.vo.response.tree.TreeUtils;
import cn.axzo.maokai.api.vo.response.tree.Value;
import cn.axzo.maokai.api.vo.response.tree.ValueNode;
import cn.axzo.maokai.api.vo.response.tree.ValueNodeRecursiveVisitor;
import cn.axzo.maokai.api.vo.response.tree.WalkingDecision;
@ -29,6 +31,10 @@ public class IndexNodeTreeUtils {
private final DocProps docProps;
public static <T extends Value> RootNode<T> build(List<T> values) {
return TreeBuilder.build(values, true);
}
public RootNode<IndexNodeInfo> transform(List<IndexNode> subtreeNodes) {
RootNode<IndexNodeInfo> root = TreeUtils.transform(subtreeNodes, IndexNodeInfo.class, true);
TreeUtils.connectValueChildren(root);