diff --git a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java index 0ba1a1401d..4f43c564d1 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestPlanController.java @@ -14,6 +14,7 @@ import io.metersphere.track.dto.TestPlanDTOWithMetric; import io.metersphere.track.request.testcase.PlanCaseRelevanceRequest; import io.metersphere.track.request.testcase.QueryTestPlanRequest; import io.metersphere.track.request.testplan.AddTestPlanRequest; +import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest; import io.metersphere.track.service.TestPlanProjectService; import io.metersphere.track.service.TestPlanService; import org.apache.shiro.authz.annotation.Logical; @@ -111,8 +112,18 @@ public class TestPlanController { return testPlanService.getProjectNameByPlanId(planId); } - @GetMapping("/project/{planId}") - public List getProjectByPlanId(@PathVariable String planId) { - return testPlanProjectService.getProjectByPlanId(planId); + @PostMapping("/project") + public List getProjectByPlanId(@RequestBody TestCaseRelevanceRequest request) { + List projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId()); + request.setProjectIds(projectIds); + return testPlanProjectService.getProjectByPlanId(request); + } + + @PostMapping("/project/{goPage}/{pageSize}") + public Pager> getProjectByPlanId(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody TestCaseRelevanceRequest request) { + List projectIds = testPlanProjectService.getProjectIdsByPlanId(request.getPlanId()); + request.setProjectIds(projectIds); + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, testPlanProjectService.getProjectByPlanId(request)); } } diff --git a/backend/src/main/java/io/metersphere/track/request/testplancase/TestCaseRelevanceRequest.java b/backend/src/main/java/io/metersphere/track/request/testplancase/TestCaseRelevanceRequest.java new file mode 100644 index 0000000000..14030b8596 --- /dev/null +++ b/backend/src/main/java/io/metersphere/track/request/testplancase/TestCaseRelevanceRequest.java @@ -0,0 +1,14 @@ +package io.metersphere.track.request.testplancase; + +import lombok.Getter; +import lombok.Setter; + +import java.util.List; + +@Getter +@Setter +public class TestCaseRelevanceRequest { + private String planId; + private String name; + private List projectIds; +} diff --git a/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java b/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java index 49cb890fe4..42a2774cf5 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestPlanProjectService.java @@ -6,26 +6,25 @@ import io.metersphere.base.domain.TestPlanProject; import io.metersphere.base.domain.TestPlanProjectExample; import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.TestPlanProjectMapper; -import org.python.antlr.ast.Str; +import io.metersphere.track.request.testplancase.TestCaseRelevanceRequest; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; import javax.annotation.Resource; -import java.util.ArrayList; import java.util.List; -import java.util.Optional; import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) public class TestPlanProjectService { - + @Resource TestPlanProjectMapper testPlanProjectMapper; @Resource ProjectMapper projectMapper; - + public List getProjectIdsByPlanId(String planId) { TestPlanProjectExample example = new TestPlanProjectExample(); example.createCriteria().andTestPlanIdEqualTo(planId); @@ -41,12 +40,14 @@ public class TestPlanProjectService { return projectIds; } - public List getProjectByPlanId(String planId) { - List projectIds = getProjectIdsByPlanId(planId); + public List getProjectByPlanId(TestCaseRelevanceRequest request) { ProjectExample projectExample = new ProjectExample(); - projectExample.createCriteria().andIdIn(projectIds); - List projects = projectMapper.selectByExample(projectExample); - return Optional.ofNullable(projects).orElse(new ArrayList<>()); + ProjectExample.Criteria criteria = projectExample.createCriteria(); + criteria.andIdIn(request.getProjectIds()); + if (StringUtils.isNotBlank(request.getName())) { + criteria.andNameLike(StringUtils.wrapIfMissing(request.getName(), "%")); + } + return projectMapper.selectByExample(projectExample); } public void deleteTestPlanProjectByPlanId(String planId) { diff --git a/frontend/src/business/components/track/case/components/SwitchProject.vue b/frontend/src/business/components/track/case/components/SwitchProject.vue index 9170bc4241..57b9335340 100644 --- a/frontend/src/business/components/track/case/components/SwitchProject.vue +++ b/frontend/src/business/components/track/case/components/SwitchProject.vue @@ -1,86 +1,101 @@ diff --git a/frontend/src/business/components/track/plan/components/TestPlanList.vue b/frontend/src/business/components/track/plan/components/TestPlanList.vue index 98293943e9..a2aee7c3da 100644 --- a/frontend/src/business/components/track/plan/components/TestPlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestPlanList.vue @@ -192,8 +192,8 @@ export default { this.total = data.itemCount; this.tableData = data.listObject; for (let i = 0; i < this.tableData.length; i++) { - let path = "/test/plan/project/" + this.tableData[i].id; - this.$get(path, res => { + let path = "/test/plan/project"; + this.$post(path,{planId: this.tableData[i].id}, res => { let arr = res.data; let projectName = arr.map(data => data.name).join("、"); let projectIds = arr.map(data => data.id); diff --git a/frontend/src/business/components/track/plan/view/comonents/TestCaseRelevance.vue b/frontend/src/business/components/track/plan/view/comonents/TestCaseRelevance.vue index 786f2e4c4c..04e484e6fc 100644 --- a/frontend/src/business/components/track/plan/view/comonents/TestCaseRelevance.vue +++ b/frontend/src/business/components/track/plan/view/comonents/TestCaseRelevance.vue @@ -256,7 +256,7 @@ }, getProject() { if (this.planId) { - this.$get("/test/plan/project/" + this.planId,res => { + this.$post("/test/plan/project/", {planId: this.planId},res => { let data = res.data; if (data) { this.projects = data;