diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java index 3cc6ebe9ef..de8ac93356 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/controller/definition/ApiTestCaseController.java @@ -160,7 +160,7 @@ public class ApiTestCaseController { public Pager> page(@Validated @RequestBody ApiTestCasePageRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString("id")) ? request.getSortString("id") : "pos desc, id desc"); - return PageUtils.setPageInfo(page, apiTestCaseService.page(request, false)); + return PageUtils.setPageInfo(page, apiTestCaseService.page(request, false, true)); } @PostMapping("/batch/delete") @@ -202,7 +202,7 @@ public class ApiTestCaseController { public Pager> pageTrash(@Validated @RequestBody ApiTestCasePageRequest request) { Page page = PageHelper.startPage(request.getCurrent(), request.getPageSize(), StringUtils.isNotBlank(request.getSortString("id")) ? request.getSortString("id") : "delete_time desc, id desc"); - return PageUtils.setPageInfo(page, apiTestCaseService.page(request, true)); + return PageUtils.setPageInfo(page, apiTestCaseService.page(request, true, true)); } @PostMapping("/edit/pos") diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleRequest.java b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleRequest.java index d0f97cb2a4..ad151527ce 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleRequest.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/dto/definition/ApiModuleRequest.java @@ -33,4 +33,7 @@ public class ApiModuleRequest extends BaseCondition { @Schema(description = "版本引用fk") @Size(max = 50, message = "{api_definition.ref_id.length_range}") private String refId; + + @Schema(description = "测试计划id") + private String testPlanId; } diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java index 2eccce47e3..1648dba135 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.java @@ -30,7 +30,7 @@ public interface ExtApiDefinitionModuleMapper { List selectApiDataByRequest(@Param("request") ApiModuleRequest request, @Param("deleted") boolean deleted); - List countModuleIdByRequest(@Param("request") ApiModuleRequest request, @Param("deleted") boolean deleted); + List countModuleIdByRequest(@Param("request") ApiModuleRequest request, @Param("deleted") boolean deleted, @Param("isRepeat") boolean isRepeat); List selectNodeByIds(@Param("ids") List ids); diff --git a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.xml b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.xml index a58771cc9b..99e34ab0ba 100644 --- a/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.xml +++ b/backend/services/api-test/src/main/java/io/metersphere/api/mapper/ExtApiDefinitionModuleMapper.xml @@ -53,6 +53,21 @@ FROM api_definition where api_definition.deleted = #{deleted} + + and exists ( + select id + from api_test_case c + where c.api_definition_id = api_definition.id and c.deleted = false + + and not exists ( + select id + from test_plan_api_case t + where t.api_case_id = c.id + and t.test_plan_id = #{request.testPlanId} + ) + + ) + GROUP BY api_definition.module_id