From 0f2ba1d329ce7a4b46ae84230c12a0f00f7eb5d0 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Mon, 3 Jun 2024 15:17:17 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E5=85=B3=E8=81=94=E6=8A=BD=E5=B1=89=E6=8E=A5=E5=8F=A3=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../definition/ApiTestCaseController.java | 4 +-- .../api/dto/definition/ApiModuleRequest.java | 3 ++ .../mapper/ExtApiDefinitionModuleMapper.java | 2 +- .../mapper/ExtApiDefinitionModuleMapper.xml | 15 +++++++++ .../api/mapper/ExtApiTestCaseMapper.java | 2 +- .../api/mapper/ExtApiTestCaseMapper.xml | 5 +++ .../ApiDefinitionModuleService.java | 15 ++++++++- .../definition/ApiTestCaseService.java | 4 +-- .../ApiDefinitionModuleControllerTests.java | 14 ++++++++- .../TestPlanAssociateController.java | 29 +++++++++++++++++ .../dto/request/TestPlanApiCaseRequest.java | 17 ++++++++++ .../plan/service/TestPlanApiCaseService.java | 25 +++++++++++++++ .../service/TestPlanManagementService.java | 23 ++++++++++++-- .../TestPlanAssociateControllerTests.java | 31 +++++++++++++++++-- .../dml/init_test_plan_association.sql | 26 +++++++++------- 15 files changed, 192 insertions(+), 23 deletions(-) create mode 100644 backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanApiCaseRequest.java 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