From 64b6b6a9caaf83c0ce022f0551e8db37eb01e084 Mon Sep 17 00:00:00 2001 From: fit2-zhao Date: Mon, 14 Mar 2022 14:13:04 +0800 Subject: [PATCH] =?UTF-8?q?refactor=20(=E6=8E=A5=E5=8F=A3=E6=B5=8B?= =?UTF-8?q?=E8=AF=95):=20=E4=BC=98=E5=8C=96=E5=9C=BA=E6=99=AF=E6=AD=A5?= =?UTF-8?q?=E9=AA=A4=E5=88=9D=E5=A7=8B=E5=8C=96=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/service/ApiDefinitionService.java | 5 +++-- .../metersphere/api/service/MsHashTreeService.java | 12 +++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index 76624c50f3..d72eae0d1c 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1174,7 +1174,7 @@ public class ApiDefinitionService { .build(); noticeSendService.send(NoticeConstants.Mode.SCHEDULE, "", noticeModel); } - }catch (Exception e){ + } catch (Exception e) { LogUtil.error(e); MSException.throwException(Translator.get("user_import_format_wrong")); } @@ -1809,13 +1809,14 @@ public class ApiDefinitionService { public ApiDefinitionResult getById(String id) { ApiDefinitionRequest request = new ApiDefinitionRequest(); request.setId(id); - List list = list(request); + List list = extApiDefinitionMapper.list(request); if (CollectionUtils.isNotEmpty(list)) { return list.get(0); } return null; } + public long countEffectiveByProjectId(String projectId) { if (StringUtils.isEmpty(projectId)) { return 0; diff --git a/backend/src/main/java/io/metersphere/api/service/MsHashTreeService.java b/backend/src/main/java/io/metersphere/api/service/MsHashTreeService.java index a315c10030..8ff9f2161d 100644 --- a/backend/src/main/java/io/metersphere/api/service/MsHashTreeService.java +++ b/backend/src/main/java/io/metersphere/api/service/MsHashTreeService.java @@ -201,11 +201,13 @@ public class MsHashTreeService { this.setElement(element, apiTestCase.getNum(), enable, apiTestCase.getVersionName(), apiTestCase.getVersionEnable()); } } else { - ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString(ID)); - if (definitionWithBLOBs != null) { - element.put(ID, definitionWithBLOBs.getId()); - this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable()); - isExist = true; + if (StringUtils.equalsIgnoreCase(element.getString(REFERENCED), "Copy")) { + ApiDefinitionResult definitionWithBLOBs = apiDefinitionService.getById(element.getString(ID)); + if (definitionWithBLOBs != null) { + element.put(ID, definitionWithBLOBs.getId()); + this.setElement(element, definitionWithBLOBs.getNum(), enable, definitionWithBLOBs.getVersionName(), definitionWithBLOBs.getVersionEnable()); + isExist = true; + } } } if (!isExist) {