From 17648859381be631f675f712a7e0974170bd9e9b Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Fri, 8 Nov 2024 11:21:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92):=20?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E8=AE=A1=E5=88=92&=E8=AE=A1=E5=88=92?= =?UTF-8?q?=E7=BB=84=E9=AB=98=E7=BA=A7=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/request/TestPlanTableRequest.java | 1 + .../plan/mapper/ExtTestPlanMapper.java | 3 + .../plan/mapper/ExtTestPlanMapper.xml | 352 +++++++++++++++++- .../service/TestPlanManagementService.java | 50 ++- .../plan/controller/TestPlanTests.java | 21 ++ 5 files changed, 408 insertions(+), 19 deletions(-) diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java index 7bc858a232..12abdb2bdd 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/dto/request/TestPlanTableRequest.java @@ -28,6 +28,7 @@ public class TestPlanTableRequest extends BasePageRequest { @Schema(description = "通过其他条件查询出来的,必须要包含的测试计划ID") private List innerIds; + private List combineInnerIds; public String getSortString() { if (StringUtils.isEmpty(super.getSortString())) { diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java index 9483a3fd6d..87f5b68839 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.java @@ -78,4 +78,7 @@ public interface ExtTestPlanMapper { List projectPlanCount(@Param("projectIds") Set projectIds, @Param("startTime") long startTime, @Param("endTime") long endTime, @Param("userId") String userId); + @BaseConditionFilter + List selectMyFollowByConditions(@Param("request") TestPlanTableRequest request); + } diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml index b12bdc81da..a51742f79e 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/mapper/ExtTestPlanMapper.xml @@ -123,6 +123,12 @@ ) --> + + and t.id in + + #{id} + + @@ -180,11 +186,104 @@ + + + + + + + - - - - + + + + + + + + + + + + + or t.id in + ( + SELECT group_id + FROM test_plan + WHERE project_id = #{request.projectId} + AND + + + + + ) + + + + + + + + + + or t.id in + ( + SELECT group_id + FROM test_plan + WHERE project_id = #{request.projectId} + AND + + + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + or t.id in + ( + SELECT group_id + FROM test_plan + WHERE project_id = #{request.projectId} + AND + + + + + ) + + + @@ -641,4 +740,249 @@ group by test_plan.project_id; + + + + + + + + + and ( + t.name like concat('%', #{request.keyword},'%') + or t.num like concat('%', #{request.keyword},'%') + or t.tags like concat('%', #{request.keyword}, '%') + + or t.id in + + #{id} + + + ) + + + and t.id in + + #{id} + + + + and t.id in + + #{id} + + + + + + + + + + + + + + + + + + + + + + + + + + + t.id IN ( + SELECT + test_plan.group_id + FROM + test_plan_follower + INNER JOIN test_plan on test_plan_follower.test_plan_id = test_plan.id + WHERE + test_plan.project_id = #{request.projectId} + and test_plan_follower.user_id IN + + #{v} + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + or t.id in + ( + SELECT group_id + FROM test_plan + WHERE project_id = #{request.projectId} + AND + + + + + ) + + + + + + + + + + or t.id in + ( + SELECT group_id + FROM test_plan + WHERE project_id = #{request.projectId} + AND + + + + + ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + or t.id in + ( + SELECT group_id + FROM test_plan + WHERE project_id = #{request.projectId} + AND + + + + + ) + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java index 00517aefc1..dd4d6dcbb2 100644 --- a/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java +++ b/backend/services/test-plan/src/main/java/io/metersphere/plan/service/TestPlanManagementService.java @@ -185,24 +185,39 @@ public class TestPlanManagementService { @Autowired private ApplicationContext applicationContext; + private void initDefaultFilter(TestPlanTableRequest request) { List defaultStatusList = new ArrayList<>(); defaultStatusList.add(TestPlanConstants.TEST_PLAN_STATUS_NOT_ARCHIVED); - if (request.getFilter() == null || !request.getFilter().containsKey("status")) { - if (request.getFilter() == null) { - request.setFilter(new HashMap<>() {{ - this.put("status", defaultStatusList); - }}); - } else { + Optional.ofNullable(request.getCombineSearch()).ifPresent(combineSearch -> { + combineSearch.getConditions().forEach(item -> { + if (StringUtils.equalsIgnoreCase(item.getName(), "status")) { + List statusList = (List) item.getValue(); + item.setValue(defaultStatusList); + //目前未归档的测试计划只有3中类型。所以这里判断如果是3个的话等于直接查询未归档 + if (statusList.size() < 3) { + request.setCombineInnerIds(this.selectTestPlanIdByProjectIdAndStatus(request.getProjectId(), statusList)); + } + } + }); + }); + if (!StringUtils.equalsIgnoreCase(request.getViewId(), TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) { + if (request.getFilter() == null || !request.getFilter().containsKey("status")) { + if (request.getFilter() == null) { + request.setFilter(new HashMap<>() {{ + this.put("status", defaultStatusList); + }}); + } else { + request.getFilter().put("status", defaultStatusList); + } + } else if (!request.getFilter().get("status").contains(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) { + List statusList = request.getFilter().get("status"); request.getFilter().put("status", defaultStatusList); - } - } else if (!request.getFilter().get("status").contains(TestPlanConstants.TEST_PLAN_STATUS_ARCHIVED)) { - List statusList = request.getFilter().get("status"); - request.getFilter().put("status", defaultStatusList); - //目前未归档的测试计划只有3中类型。所以这里判断如果是3个的话等于直接查询未归档 - if (statusList.size() < 3) { - request.setInnerIds(this.selectTestPlanIdByProjectIdAndStatus(request.getProjectId(), statusList)); + //目前未归档的测试计划只有3中类型。所以这里判断如果是3个的话等于直接查询未归档 + if (statusList.size() < 3) { + request.setInnerIds(this.selectTestPlanIdByProjectIdAndStatus(request.getProjectId(), statusList)); + } } } @@ -216,8 +231,13 @@ public class TestPlanManagementService { } public List list(TestPlanTableRequest request) { - List testPlanResponses = extTestPlanMapper.selectByConditions(request); - handChildren(testPlanResponses,request.getProjectId()); + List testPlanResponses = new ArrayList<>(); + if (StringUtils.equalsIgnoreCase(request.getViewId(), "my_follow")) { + testPlanResponses = extTestPlanMapper.selectMyFollowByConditions(request); + } else { + testPlanResponses = extTestPlanMapper.selectByConditions(request); + } + handChildren(testPlanResponses, request.getProjectId()); return testPlanResponses; } diff --git a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java index 8fda78d460..ea6f3ac01f 100644 --- a/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java +++ b/backend/services/test-plan/src/test/java/io/metersphere/plan/controller/TestPlanTests.java @@ -21,6 +21,8 @@ import io.metersphere.project.dto.filemanagement.request.FileModuleCreateRequest import io.metersphere.project.dto.filemanagement.request.FileModuleUpdateRequest; import io.metersphere.project.mapper.ProjectMapper; import io.metersphere.sdk.constants.*; +import io.metersphere.sdk.dto.CombineCondition; +import io.metersphere.sdk.dto.CombineSearch; import io.metersphere.sdk.util.BeanUtils; import io.metersphere.sdk.util.CommonBeanFactory; import io.metersphere.sdk.util.JSON; @@ -237,7 +239,26 @@ public class TestPlanTests extends BaseTest { this.requestGetPermissionTest(PermissionConstants.TEST_PLAN_READ, String.format(URL_GET_MODULE_TREE, DEFAULT_PROJECT_ID)); testPlanTableRequest.setProjectId(DEFAULT_PROJECT_ID); this.requestPostPermissionTest(PermissionConstants.TEST_PLAN_READ, URL_POST_TEST_PLAN_PAGE, testPlanTableRequest); + + testPlanTableRequest.setViewId("my-follow"); + testPlanTableRequest.setCombineSearch(buildCombineSearch()); + this.requestPost(URL_POST_TEST_PLAN_PAGE, testPlanTableRequest); } + + private CombineSearch buildCombineSearch() { + CombineSearch combineSearch = new CombineSearch(); + List conditions = new ArrayList<>(); + CombineCondition combineCondition = new CombineCondition(); + combineCondition.setName("status"); + combineCondition.setValue(List.of("PREPARED")); + combineCondition.setOperator("IN"); + combineCondition.setCustomField(false); + combineCondition.setCustomFieldType(""); + conditions.add(combineCondition); + combineSearch.setConditions(conditions); + return combineSearch; + } + @Test @Order(2) public void addModuleTest() throws Exception {