diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java index eac1f9cd67..19815df0a1 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/FileModuleService.java @@ -44,13 +44,13 @@ public class FileModuleService extends ModuleTreeService implements CleanupProje public List getTree(String projectId) { List fileModuleList = extFileModuleMapper.selectBaseByProjectId(projectId); - return super.buildTreeAndCountResource(fileModuleList, true); + return super.buildTreeAndCountResource(fileModuleList, true, Translator.get("default.module")); } public List getTreeOnlyIdsAndResourceCount(String projectId, List moduleCountDTOList) { //节点内容只有Id和parentId List fileModuleList = extFileModuleMapper.selectIdAndParentIdByProjectId(projectId); - return super.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true); + return super.buildTreeAndCountResource(fileModuleList, moduleCountDTOList, true, Translator.get("default.module")); } public String add(FileModuleCreateRequest request, String operator) { diff --git a/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java b/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java index d986413624..4599ad2b9a 100644 --- a/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java +++ b/backend/services/project-management/src/main/java/io/metersphere/project/service/ModuleTreeService.java @@ -5,7 +5,6 @@ import io.metersphere.project.dto.NodeSortDTO; import io.metersphere.sdk.constants.ModuleConstants; import io.metersphere.system.dto.sdk.BaseModule; import io.metersphere.system.dto.sdk.BaseTreeNode; -import io.metersphere.sdk.util.Translator; import jakarta.validation.constraints.NotNull; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -21,16 +20,16 @@ public abstract class ModuleTreeService { protected static final int LIMIT_POS = 64; - public BaseTreeNode getDefaultModule() { + public BaseTreeNode getDefaultModule(String name) { //默认模块下不允许创建子模块。 它本身也就是叶子节点。 - return new BaseTreeNode(ModuleConstants.DEFAULT_NODE_ID, Translator.get("default.module"), ModuleConstants.NODE_TYPE_DEFAULT, ModuleConstants.ROOT_NODE_PARENT_ID); + return new BaseTreeNode(ModuleConstants.DEFAULT_NODE_ID, name, ModuleConstants.NODE_TYPE_DEFAULT, ModuleConstants.ROOT_NODE_PARENT_ID); } //构建树结构,并为每个节点计算资源数量 - public List buildTreeAndCountResource(List traverseList, @NotNull List moduleCountDTOList, boolean haveVirtualRootNode) { + public List buildTreeAndCountResource(List traverseList, @NotNull List moduleCountDTOList, boolean haveVirtualRootNode, String virtualRootName) { //构建模块树 - List baseTreeNodeList = this.buildTreeAndCountResource(traverseList, haveVirtualRootNode); + List baseTreeNodeList = this.buildTreeAndCountResource(traverseList, haveVirtualRootNode, virtualRootName); //构建模块节点统计的数据结构 Map resourceCountMap = moduleCountDTOList.stream().collect(Collectors.toMap(ModuleCountDTO::getModuleId, ModuleCountDTO::getDataCount)); //为每个节点赋值资源数量 @@ -44,10 +43,10 @@ public abstract class ModuleTreeService { * @param traverseList 要遍历的节点集合(会被清空) * @param haveVirtualRootNode 是否包含虚拟跟节点 */ - public List buildTreeAndCountResource(List traverseList, boolean haveVirtualRootNode) { + public List buildTreeAndCountResource(List traverseList, boolean haveVirtualRootNode, String virtualRootName) { List baseTreeNodeList = new ArrayList<>(); if (haveVirtualRootNode) { - BaseTreeNode defaultNode = this.getDefaultModule(); + BaseTreeNode defaultNode = this.getDefaultModule(virtualRootName); baseTreeNodeList.add(defaultNode); } int lastSize = 0;