From d083774987761eb8505ed1c0de9169a73f3b40eb Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 17 Jun 2024 11:12:42 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):?= =?UTF-8?q?=20=E4=BC=98=E5=8C=96=E6=8E=A5=E5=8F=A3=E5=88=97=E8=A1=A8?= =?UTF-8?q?=E8=BF=94=E5=9B=9E=E5=80=BC&=E6=9F=A5=E8=AF=A2sql?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plan/dto/response/TestPlanApiScenarioPageResponse.java | 3 +++ .../io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java | 2 +- .../io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml | 1 + .../metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml | 1 + .../io/metersphere/plan/service/TestPlanApiCaseService.java | 5 +++-- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanApiScenarioPageResponse.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanApiScenarioPageResponse.java index 7da8d7a331..cdb1432894 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanApiScenarioPageResponse.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/response/TestPlanApiScenarioPageResponse.java @@ -67,4 +67,7 @@ public class TestPlanApiScenarioPageResponse implements Serializable { @Schema(description = "状态") private String status; + + @Schema(description = "场景用例的id") + private String apiScenarioId; } \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java index 68b6c5645c..06da44d816 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.java @@ -69,7 +69,7 @@ public interface ExtTestPlanApiCaseMapper { List getApiCaseExecuteInfoByIds(@Param("ids") List ids); - List selectApiCaseByDefinitionIds(@Param("ids") List ids, @Param("isRepeat") boolean isRepeat); + List selectApiCaseByDefinitionIds(@Param("ids") List ids, @Param("isRepeat") boolean isRepeat, @Param("testPlanId") String testPlanId); List getSelectIdAndCollectionId(@Param("request") TestPlanApiCaseBatchRequest request); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml index 5833c8dc94..ca5d9f0a7e 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiCaseMapper.xml @@ -702,6 +702,7 @@ api_case_id FROM test_plan_api_case + where test_plan_api_case.test_plan_id = #{testPlanId} ) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml index af8cec5f78..2eff675cf2 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanApiScenarioMapper.xml @@ -93,6 +93,7 @@ api_scenario.project_id, api_scenario.create_user, api_scenario.status, + api_scenario.id as apiScenarioId, test_plan_api_scenario.create_time, test_plan_api_scenario.environment_id, api_scenario.module_id, diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java index 5b159e717e..761bd6b722 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiCaseService.java @@ -551,7 +551,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService { if (CollectionUtils.isNotEmpty(apiCaseList)) { List ids = apiCaseList.stream().flatMap(item -> item.getIds().stream()).toList(); boolean isRepeat = testPlanConfigService.isRepeatCase(testPlan.getId()); - List apiTestCaseList = extTestPlanApiCaseMapper.selectApiCaseByDefinitionIds(ids, isRepeat); + List apiTestCaseList = extTestPlanApiCaseMapper.selectApiCaseByDefinitionIds(ids, isRepeat, testPlan.getId()); apiCaseList.forEach(apiCase -> { List apiCaseIds = apiCase.getIds(); if (CollectionUtils.isNotEmpty(apiCaseIds)) { @@ -684,9 +684,10 @@ public class TestPlanApiCaseService extends TestPlanResourceService { /** * 预生成用例的执行报告 + * * @return */ - public ApiTestCaseRecord initApiReport(ApiTestCase apiTestCase, TestPlanApiCase testPlanApiCase, String reportId, ApiRunModeConfigDTO runModeConfig, String userId) { + public ApiTestCaseRecord initApiReport(ApiTestCase apiTestCase, TestPlanApiCase testPlanApiCase, String reportId, ApiRunModeConfigDTO runModeConfig, String userId) { // 初始化报告 ApiReport apiReport = apiTestCaseService.getApiReport(apiTestCase, reportId, runModeConfig.getPoolId(), userId); apiReport.setEnvironmentId(runModeConfig.getEnvironmentId());