From a3c0ec4acaaa378e261d3a367c8f06bf7258a31c Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Tue, 20 Dec 2022 17:59:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E9=80=9A=E7=94=A8=E5=8A=9F=E8=83=BD):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=B8=AA=E7=89=88=E6=9C=AC=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E4=BF=AE=E6=94=B9=E5=85=B6=E4=BB=96=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=8D=E8=B7=9F=E9=9A=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021055--user=郭雨琦 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001021055 --- .../base/mapper/ext/ExtApiDefinitionMapper.java | 2 ++ .../base/mapper/ext/ExtApiDefinitionMapper.xml | 8 ++++++++ .../metersphere/base/mapper/ext/ExtApiScenarioMapper.java | 2 ++ .../metersphere/base/mapper/ext/ExtApiScenarioMapper.xml | 8 ++++++++ .../service/definition/ApiDefinitionService.java | 7 ++++++- .../metersphere/service/plan/TestPlanApiCaseService.java | 2 +- .../service/plan/TestPlanScenarioCaseService.java | 2 +- .../metersphere/service/scenario/ApiScenarioService.java | 6 ++++++ .../io/metersphere/base/mapper/ext/ExtTestCaseMapper.java | 3 +++ .../io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml | 8 ++++++++ .../main/java/io/metersphere/service/TestCaseService.java | 6 ++++++ 11 files changed, 51 insertions(+), 3 deletions(-) diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java index a54980c99f..66b1cbf281 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.java @@ -85,6 +85,8 @@ public interface ExtApiDefinitionMapper { void addLatestVersion(String refId); + void updateVersionModule(@Param("refId") String refId, @Param("versionId") String versionId, @Param("moduleId") String moduleId, @Param("modulePath") String modulePath); + List selectRefIdsForVersionChange(@Param("versionId") String versionId, @Param("projectId") String projectId); String selectNameById(String testId); diff --git a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml index e88172554e..ff8efe9324 100644 --- a/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml +++ b/api-test/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiDefinitionMapper.xml @@ -1168,6 +1168,14 @@ SELECT id FROM api_module WHERE project_id = #{projectId} AND protocol = #{protocol} ) + + + UPDATE api_definition + SET module_id = #{moduleId}, + module_path = #{modulePath} + WHERE ref_id = #{refId} + AND version_id != #{versionId} + SELECT DISTINCT ref_id FROM api_scenario 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 590113bc4e..79f42e5133 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 @@ -787,7 +787,8 @@ public class ApiDefinitionService { if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { checkAndSetLatestVersion(result.getRefId()); } - + //同步修改所有版本的模块路径 + updateOtherVersionModule(result); // 存储附件关系 extFileAssociationService.saveApi(test.getId(), request.getRequest(), FileAssociationTypeEnums.API.name()); //保存自定义字段 @@ -796,6 +797,10 @@ public class ApiDefinitionService { return result; } + private void updateOtherVersionModule(ApiDefinitionWithBLOBs result) { + extApiDefinitionMapper.updateVersionModule(result.getRefId(), result.getVersionId(), result.getModuleId(), result.getModulePath()); + } + private void saveExtendInfo(SaveApiDefinitionRequest request, ApiDefinitionWithBLOBs test, ApiDefinitionWithBLOBs oldApi) { // 创建新版是否关联备注 if (!request.isNewVersionRemark()) { diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java index 4d726e1f00..f94b6e1bc9 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanApiCaseService.java @@ -829,6 +829,6 @@ public class TestPlanApiCaseService { ApiTestCaseExample example = new ApiTestCaseExample(); example.createCriteria().andIdIn(apiCaseIds); List apiTestCases = apiTestCaseMapper.selectByExample(example); - return apiTestCases.stream().map(ApiTestCase::getProjectId).collect(Collectors.toList()); + return apiTestCases.stream().map(ApiTestCase::getProjectId).distinct().collect(Collectors.toList()); } } diff --git a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java index 673eac2f64..a211918032 100644 --- a/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java +++ b/api-test/backend/src/main/java/io/metersphere/service/plan/TestPlanScenarioCaseService.java @@ -1257,6 +1257,6 @@ public class TestPlanScenarioCaseService { ApiScenarioExample example = new ApiScenarioExample(); example.createCriteria().andIdIn(scenarioIds); List apiScenarios = apiScenarioMapper.selectByExample(example); - return apiScenarios.stream().map(ApiScenario::getProjectId).collect(Collectors.toList()); + return apiScenarios.stream().map(ApiScenario::getProjectId).distinct().collect(Collectors.toList()); } } 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 e0df117ce0..7bd3d1e3aa 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 @@ -413,11 +413,17 @@ public class ApiScenarioService { if (StringUtils.equalsIgnoreCase(request.getVersionId(), defaultVersion)) { checkAndSetLatestVersion(beforeScenario.getRefId()); } + //同步修改所有版本的模块路径 + updateOtherVersionModule(beforeScenario.getRefId(), scenario); // 存储附件关系 extFileAssociationService.saveScenario(scenario.getId(), request.getScenarioDefinition()); return scenario; } + private void updateOtherVersionModule(String refId, ApiScenarioWithBLOBs scenario) { + extApiScenarioMapper.updateVersionModule(refId, scenario.getVersionId(), scenario.getApiScenarioModuleId(), scenario.getModulePath()); + } + private void checkReferenceCase(ApiScenarioWithBLOBs scenario, ApiScenarioParamDTO apiScenarioParamDto) { if (scenario == null || StringUtils.isEmpty(scenario.getScenarioDefinition())) { return; diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index 3c6b80c4f6..9fffc9c340 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -150,6 +150,9 @@ public interface ExtTestCaseMapper { int addLatestVersion(@Param("refId") String refId); + void updateVersionModule(@Param("refId") String refId, @Param("versionId") String versionId, @Param("moduleId") String moduleId, @Param("modulePath") String modulePath); + + List getMaintainerMap(@Param("request") QueryTestCaseRequest request); List getForNodeEdit(@Param("ids") List ids); diff --git a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 0b651f7bdc..5ec84f4676 100644 --- a/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/test-track/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -1266,6 +1266,14 @@ WHERE ref_id = #{refId,jdbcType=VARCHAR} + + UPDATE test_case + SET node_id = #{moduleId}, + node_path = #{modulePath} + WHERE ref_id = #{refId} + AND version_id != #{versionId} + + update test_case 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 83d7481c47..5ce24bfaae 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 @@ -467,9 +467,15 @@ public class TestCaseService { if (StringUtils.equalsIgnoreCase(testCase.getVersionId(), defaultVersion)) { checkAndSetLatestVersion(testCase.getRefId()); } + //同步修改所有版本的模块路径 + updateOtherVersionModule(testCase); } + private void updateOtherVersionModule(EditTestCaseRequest testCase) { + extTestCaseMapper.updateVersionModule(testCase.getRefId(), testCase.getVersionId(), testCase.getNodeId(), testCase.getNodePath()); + } + /** * 处理其他信息的复制问题 *