提交 9afc16c4 作者: obcy

编辑知识库分类父级节点bug

上级 174fea68
......@@ -94,7 +94,7 @@ public class KbKnowledgeProjectServiceImpl extends ServiceImpl<KbKnowledgeProjec
public Result<?> edit(KbKnowledgeProject knowledgeProject) {
KbKnowledgeProject byId = super.getById(knowledgeProject.getId());
if (ObjectUtils.isEmpty(byId)){
return Result.error("未找到对应的知识库");
return Result.error("未找到对应的知识库分类id");
}
String oldPid = byId.getPid();
String newPid = knowledgeProject.getPid();
......@@ -120,20 +120,29 @@ public class KbKnowledgeProjectServiceImpl extends ServiceImpl<KbKnowledgeProjec
String finalNewPid = newPid;
if (!KbKnowledgeProjectService.ROOT_PID_VALUE.equals(finalNewPid)) {
/**非根节点 移动到其他非根节点*/
KbKnowledgeProject projectPid = super.getById(finalNewPid);
if (!KbKnowledgeProjectService.ROOT_PID_VALUE.equals(oldPid)) {
String id = knowledgeProject.getId();
String fullPath = knowledgeProject.getFullPath();
String replace = fullPath.replace(id, "");
list.forEach(e->{
e.setFullPath(e.getFullPath().replace(oldPid, finalNewPid));
e.setFullPath(projectPid.getFullPath()+"," + e.getFullPath().replace(replace, ""));
});
}else {
/**根节点 移动到其他非根节点*/
list.forEach(e->{
e.setFullPath(finalNewPid+","+e.getFullPath());
e.setFullPath(projectPid.getFullPath()+","+e.getFullPath());
});
}
}else {
String id = knowledgeProject.getId();
String fullPath = knowledgeProject.getFullPath();
String replace = fullPath.replace(id, "");
/**移动到根节点*/
list.forEach(e->{
e.setFullPath(e.getFullPath().replace(oldPid+",", ""));
e.setFullPath(e.getFullPath().replace(replace, ""));
});
}
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论