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 06da44d816..653e27364a 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 @@ -9,6 +9,7 @@ import io.metersphere.plan.dto.ApiCaseModuleDTO; import io.metersphere.plan.dto.ResourceSelectParam; import io.metersphere.plan.dto.TestPlanCaseRunResultCount; import io.metersphere.plan.dto.request.TestPlanApiCaseBatchRequest; +import io.metersphere.plan.dto.request.TestPlanApiCaseModuleRequest; import io.metersphere.plan.dto.request.TestPlanApiCaseRequest; import io.metersphere.plan.dto.request.TestPlanApiRequest; import io.metersphere.plan.dto.response.TestPlanApiCasePageResponse; @@ -55,7 +56,7 @@ public interface ExtTestPlanApiCaseMapper { void batchUpdateExecutor(@Param("ids") List ids, @Param("userId") String userId); - List collectionCountByRequest(@Param("testPlanId") String testPlanId); + List collectionCountByRequest(@Param("request") TestPlanApiCaseModuleRequest request); Long getMaxPosByCollectionId(String collectionId); 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 4e1f218a15..3c84322c1a 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 @@ -641,18 +641,20 @@ - SELECT - test_plan_api_case.test_plan_collection_id AS moduleId, - count( test_plan_api_case.id ) AS dataCount + t.test_plan_collection_id AS moduleId, + count( t.id ) AS dataCount FROM - api_test_case - INNER JOIN test_plan_api_case ON api_test_case.id = test_plan_api_case.api_case_id + api_test_case atc + INNER JOIN test_plan_api_case t ON atc.id = t.api_case_id + INNER JOIN api_definition a on atc.api_definition_id = a.id WHERE - api_test_case.deleted = FALSE - AND test_plan_api_case.test_plan_id = #{testPlanId} + atc.deleted = FALSE + AND t.test_plan_id = #{request.testPlanId} + GROUP BY - test_plan_api_case.test_plan_collection_id + t.test_plan_collection_id - SELECT test_plan_api_scenario.test_plan_collection_id AS moduleId, count( test_plan_api_scenario.id ) AS dataCount @@ -360,7 +360,8 @@ INNER JOIN test_plan_api_scenario on api_scenario.id = test_plan_api_scenario.api_scenario_id WHERE api_scenario.deleted = FALSE - AND test_plan_api_scenario.test_plan_id = #{testPlanId} + AND test_plan_api_scenario.test_plan_id = #{request.testPlanId} + GROUP BY test_plan_api_scenario.test_plan_collection_id diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java index a08fec9571..a552381103 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.java @@ -7,6 +7,7 @@ import io.metersphere.plan.domain.TestPlanFunctionalCase; import io.metersphere.plan.dto.ResourceSelectParam; import io.metersphere.plan.dto.TestPlanCaseRunResultCount; import io.metersphere.plan.dto.request.BasePlanCaseBatchRequest; +import io.metersphere.plan.dto.request.TestPlanCaseModuleRequest; import io.metersphere.plan.dto.request.TestPlanCaseRequest; import io.metersphere.plan.dto.response.TestPlanCasePageResponse; import io.metersphere.project.dto.DropNode; @@ -62,5 +63,5 @@ public interface ExtTestPlanFunctionalCaseMapper { Long getMaxPosByCollectionId(String collectionId); - List collectionCountByRequest(@Param("testPlanId") String testPlanId); + List collectionCountByRequest(@Param("request") TestPlanCaseModuleRequest request); } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml index b67dd19953..abae013a1f 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanFunctionalCaseMapper.xml @@ -541,7 +541,7 @@ WHERE test_plan_collection_id = #{0} - SELECT test_plan_functional_case.test_plan_collection_id AS moduleId, count( test_plan_functional_case.id ) AS dataCount @@ -550,7 +550,8 @@ INNER JOIN test_plan_functional_case ON functional_case.id = test_plan_functional_case.functional_case_id WHERE functional_case.deleted = FALSE - AND test_plan_functional_case.test_plan_id = #{testPlanId} + AND test_plan_functional_case.test_plan_id = #{request.testPlanId} + GROUP BY test_plan_functional_case.test_plan_collection_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 9436453a02..0b332644b9 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 @@ -344,7 +344,7 @@ public class TestPlanApiCaseService extends TestPlanResourceService { private Map getCollectionCount(TestPlanApiCaseModuleRequest request) { request.setCollectionId(null); Map projectModuleCountMap = new HashMap<>(); - List list = extTestPlanApiCaseMapper.collectionCountByRequest(request.getTestPlanId()); + List list = extTestPlanApiCaseMapper.collectionCountByRequest(request); list.forEach(item -> { projectModuleCountMap.put(item.getModuleId(), (long) item.getDataCount()); }); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java index 81bb596f27..b6aba70d27 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanApiScenarioService.java @@ -478,7 +478,7 @@ public class TestPlanApiScenarioService extends TestPlanResourceService { private Map getCollectionCount(TestPlanApiScenarioModuleRequest request) { request.setCollectionId(null); Map projectModuleCountMap = new HashMap<>(); - List list = extTestPlanApiScenarioMapper.collectionCountByRequest(request.getTestPlanId()); + List list = extTestPlanApiScenarioMapper.collectionCountByRequest(request); list.forEach(item -> { projectModuleCountMap.put(item.getModuleId(), (long) item.getDataCount()); }); diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java index 45efa86e0f..b2703130cf 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanFunctionalCaseService.java @@ -371,7 +371,7 @@ public class TestPlanFunctionalCaseService extends TestPlanResourceService { private Map getCollectionCount(TestPlanCaseModuleRequest request) { request.setCollectionId(null); Map projectModuleCountMap = new HashMap<>(); - List list = extTestPlanFunctionalCaseMapper.collectionCountByRequest(request.getTestPlanId()); + List list = extTestPlanFunctionalCaseMapper.collectionCountByRequest(request); list.forEach(item -> { projectModuleCountMap.put(item.getModuleId(), (long) item.getDataCount()); });