From e89b978c8de5195a706f8b5a943b67e5257e3d59 Mon Sep 17 00:00:00 2001 From: lan-yonghui Date: Wed, 20 Dec 2023 10:31:03 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):?= =?UTF-8?q?=20=E6=8E=A5=E5=8F=A3=E7=AE=A1=E7=90=86=E6=A8=A1=E5=9D=97?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E5=AE=9A=E4=B9=89=E4=BC=98=E5=8C=96=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/definition/ApiDefinitionService.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java index c5cc46e1c9..a69258a54f 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/service/definition/ApiDefinitionService.java @@ -676,8 +676,9 @@ public class ApiDefinitionService { handleMultipleVersions(apiDefinition); } + ApiDefinitionModule apiDefinitionModule = apiDefinitionModuleMapper.selectByPrimaryKey(apiDefinition.getModuleId()); // 判断接口的模块 ID 是否存在,不存在修改模块 ID 为未规划模块 ID - if (!ModuleConstants.DEFAULT_NODE_ID.equals(apiDefinition.getModuleId()) && moduleNeedsUpdate(apiDefinition.getModuleId()) == null) { + if (!ModuleConstants.DEFAULT_NODE_ID.equals(apiDefinition.getModuleId()) && apiDefinitionModule == null) { updateApiIds.add(apiDefinition.getId()); } @@ -688,12 +689,6 @@ public class ApiDefinitionService { recoverApiRelatedData(apiIds, userId, projectId); } - private ApiDefinitionModule moduleNeedsUpdate(String moduleId) { - ApiDefinitionModule apiDefinitionModule; - apiDefinitionModule = apiDefinitionModuleMapper.selectByPrimaryKey(moduleId); - return apiDefinitionModule; - } - private void handleModule(List updateApiIds) { if(!updateApiIds.isEmpty()){ ApiDefinition updateApiDefinition = new ApiDefinition(); @@ -838,7 +833,7 @@ public class ApiDefinitionService { if(ApiDefinitionDocType.ALL.name().equals(request.getType())){ apiDefinitionDocDTO.setDocTitle(Translator.get(ALL_API)); } else { - ApiDefinitionModule apiDefinitionModule = moduleNeedsUpdate(first.getModuleId()); + ApiDefinitionModule apiDefinitionModule = apiDefinitionModuleMapper.selectByPrimaryKey(first.getModuleId()); if (apiDefinitionModule != null) { apiDefinitionDocDTO.setDocTitle(apiDefinitionModule.getName()); } else {