From fc292d686baf3f9916cc70ace72bccdb9fd1fb3f Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Fri, 16 Dec 2022 10:56:18 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E9=80=9A=E7=94=A8=E5=8A=9F=E8=83=BD):?= =?UTF-8?q?=20=E7=89=88=E6=9C=AC=E7=BD=AE=E6=96=B0=E6=9C=80=E6=96=B0?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=8D=E5=85=81=E8=AE=B8=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E6=9C=80=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1020898 --user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001020898 --- .../service/definition/ApiDefinitionService.java | 5 ++++- .../io/metersphere/service/scenario/ApiScenarioService.java | 5 ++++- .../java/io/metersphere/service/PerformanceTestService.java | 5 ++++- .../main/java/io/metersphere/service/TestCaseService.java | 6 +++++- 4 files changed, 17 insertions(+), 4 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java index 8f5f81b960..ce8caf07a3 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/definition/ApiDefinitionService.java @@ -782,7 +782,10 @@ public class ApiDefinitionService { apiTestCaseService.updateByApiDefinitionId(ids, test, request.getTriggerUpdate()); } ApiDefinitionWithBLOBs result = apiDefinitionMapper.selectByPrimaryKey(test.getId()); - //checkAndSetLatestVersion(result.getRefId()); + String defaultVersion = baseProjectVersionMapper.getDefaultVersion(request.getProjectId()); + if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { + checkAndSetLatestVersion(result.getRefId()); + } // 存储附件关系 extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name()); diff --git a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java index fbd47939ee..e0df117ce0 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/scenario/ApiScenarioService.java @@ -409,7 +409,10 @@ public class ApiScenarioService { if (relationshipEdgeService != null) { relationshipEdgeService.initRelationshipEdge(beforeScenario, scenario); } - //checkAndSetLatestVersion(beforeScenario.getRefId()); + String defaultVersion = baseProjectVersionMapper.getDefaultVersion(request.getProjectId()); + if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { + checkAndSetLatestVersion(beforeScenario.getRefId()); + } // 存储附件关系 extFileAssociationService.saveScenario(scenario.getId(), request.getScenarioDefinition()); return scenario; diff --git a/performance-test/backend/src/main/java/io/metersphere/service/PerformanceTestService.java b/performance-test/backend/src/main/java/io/metersphere/service/PerformanceTestService.java index 235bfd33d1..7d7b817084 100644 --- a/performance-test/backend/src/main/java/io/metersphere/service/PerformanceTestService.java +++ b/performance-test/backend/src/main/java/io/metersphere/service/PerformanceTestService.java @@ -325,7 +325,10 @@ public class PerformanceTestService { copyLoadTestFiles(testId, loadTest.getId()); loadTestMapper.insertSelective(loadTest); } - //checkAndSetLatestVersion(loadTest.getRefId()); + String defaultVersion = baseProjectVersionMapper.getDefaultVersion(request.getProjectId()); + if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { + checkAndSetLatestVersion(loadTest.getRefId()); + } return loadTest; } diff --git a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java index 0f85dbc882..83d7481c47 100644 --- a/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/test-track/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -463,7 +463,11 @@ public class TestCaseService { dealWithOtherInfoOfNewVersion(testCase, oldTestCase.getId()); testCaseMapper.insertSelective(testCase); } - //checkAndSetLatestVersion(testCase.getRefId()); + String defaultVersion = baseProjectVersionMapper.getDefaultVersion(testCase.getProjectId()); + if (StringUtils.equalsIgnoreCase(testCase.getVersionId(), defaultVersion)) { + checkAndSetLatestVersion(testCase.getRefId()); + } + } /**