diff --git a/backend/src/main/java/io/metersphere/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/controller/TestCaseController.java index 673baab949d1f2f74816c21074cae64e904a5068..8f5afee54f1a488c734e97d0a446ba63cc554a87 100644 --- a/backend/src/main/java/io/metersphere/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/controller/TestCaseController.java @@ -39,13 +39,7 @@ public class TestCaseController { return testCaseService.getTestCaseByNodeId(nodeIds); } - @PostMapping("/plan/list/{goPage}/{pageSize}") - public Pager> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request){ - Page page = PageHelper.startPage(goPage, pageSize, true); - return PageUtils.setPageInfo(page, testCaseService.getTestPlanCases(request)); - } - - @PostMapping("/name/all") + @PostMapping("/name") public List getTestCaseNames(@RequestBody QueryTestCaseRequest request){ return testCaseService.getTestCaseNames(request); } diff --git a/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java b/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java new file mode 100644 index 0000000000000000000000000000000000000000..d09f9ade9de0114a1d3383d6c8ae34843909aacf --- /dev/null +++ b/backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java @@ -0,0 +1,42 @@ +package io.metersphere.controller; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.base.domain.TestPlanTestCase; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; +import io.metersphere.controller.request.testcase.QueryTestCaseRequest; +import io.metersphere.dto.TestPlanCaseDTO; +import io.metersphere.service.TestPlanTestCaseService; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.List; + +@RequestMapping("/test/plan/case") +@RestController +public class TestPlanTestCaseController { + + @Resource + TestPlanTestCaseService testPlanTestCaseService; + + @PostMapping("/list/{goPage}/{pageSize}") + public Pager> getTestPlanCases(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestCaseRequest request){ + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, testPlanTestCaseService.getTestPlanCases(request)); + } + + @PostMapping("/edit") + public void editTestCase(@RequestBody TestPlanTestCase testPlanTestCase){ + testPlanTestCaseService.editTestCase(testPlanTestCase); + } + + @PostMapping("/delete/{id}") + public int deleteTestCase(@PathVariable Integer id){ + return testPlanTestCaseService.deleteTestCase(id); + } + + + +} diff --git a/backend/src/main/java/io/metersphere/dto/TestPlanCaseDTO.java b/backend/src/main/java/io/metersphere/dto/TestPlanCaseDTO.java index 19a725ec825e3d420efa6d2dba28da1516f959e2..53a06473b9aac7088fac1c6f97a09599727e8657 100644 --- a/backend/src/main/java/io/metersphere/dto/TestPlanCaseDTO.java +++ b/backend/src/main/java/io/metersphere/dto/TestPlanCaseDTO.java @@ -6,6 +6,8 @@ public class TestPlanCaseDTO extends TestCase { private String executor; private String status; + private String results; + private String remark; public String getExecutor() { return executor; @@ -22,4 +24,20 @@ public class TestPlanCaseDTO extends TestCase { public void setStatus(String status) { this.status = status; } + + public String getResults() { + return results; + } + + public void setResults(String results) { + this.results = results; + } + + public String getRemark() { + return remark; + } + + public void setRemark(String remark) { + this.remark = remark; + } } diff --git a/backend/src/main/java/io/metersphere/service/TestCaseService.java b/backend/src/main/java/io/metersphere/service/TestCaseService.java index 23aa98255017ac77617ee1a57ea390b961fcdd26..2628be8d90e415f81f1a1def7c9c24a75c90ae36 100644 --- a/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -18,6 +18,7 @@ import java.util.List; import java.util.Map; import java.util.UUID; import java.util.stream.Collectors; +import java.util.stream.Stream; @Service @Transactional(rollbackFor = Exception.class) @@ -30,10 +31,10 @@ public class TestCaseService { ExtTestCaseMapper extTestCaseMapper; @Resource - TestPlanTestCaseMapper testPlanTestCaseMapper; + TestPlanMapper testPlanMapper; @Resource - TestPlanMapper testPlanMapper; + TestPlanTestCaseMapper testPlanTestCaseMapper; public void addTestCase(TestCaseWithBLOBs testCase) { testCase.setId(UUID.randomUUID().toString()); @@ -78,17 +79,35 @@ public class TestCaseService { return testCaseMapper.selectByExampleWithBLOBs(testCaseExample); } + /** + * 获取测试用例 + * 过滤已关联 + * @param request + * @return + */ public List getTestCaseNames(QueryTestCaseRequest request) { - if ( StringUtils.isNotBlank(request.getPlanId()) ) { TestPlan testPlan = testPlanMapper.selectByPrimaryKey(request.getPlanId()); request.setProjectId(testPlan.getProjectId()); } - return extTestCaseMapper.getTestCaseNames(request); - } + List testCaseNames = extTestCaseMapper.getTestCaseNames(request); + + if ( StringUtils.isNotBlank(request.getPlanId()) ) { + TestPlanTestCaseExample testPlanTestCaseExample = new TestPlanTestCaseExample(); + testPlanTestCaseExample.createCriteria().andPlanIdEqualTo(request.getPlanId()); + List relevanceIds = testPlanTestCaseMapper.selectByExample(testPlanTestCaseExample).stream() + .map(TestPlanTestCase::getCaseId) + .collect(Collectors.toList()); + + return testCaseNames.stream() + .filter(testcase -> !relevanceIds.contains(testcase.getId())) + .collect(Collectors.toList()); + } + + return testCaseNames; - public List getTestPlanCases(QueryTestCaseRequest request) { - return extTestCaseMapper.getTestPlanTestCases(request); } + + } diff --git a/backend/src/main/java/io/metersphere/service/TestPlanTestCaseService.java b/backend/src/main/java/io/metersphere/service/TestPlanTestCaseService.java new file mode 100644 index 0000000000000000000000000000000000000000..25edba720a3772a294014471b8c268f7c65cd3cc --- /dev/null +++ b/backend/src/main/java/io/metersphere/service/TestPlanTestCaseService.java @@ -0,0 +1,37 @@ +package io.metersphere.service; + +import io.metersphere.base.domain.TestPlanTestCase; +import io.metersphere.base.mapper.TestPlanTestCaseMapper; +import io.metersphere.base.mapper.ext.ExtTestCaseMapper; +import io.metersphere.controller.request.testcase.QueryTestCaseRequest; +import io.metersphere.dto.TestPlanCaseDTO; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.List; + +@Service +@Transactional(rollbackFor = Exception.class) +public class TestPlanTestCaseService { + + @Resource + TestPlanTestCaseMapper testPlanTestCaseMapper; + + @Resource + ExtTestCaseMapper extTestCaseMapper; + + public List getTestPlanCases(QueryTestCaseRequest request) { + return extTestCaseMapper.getTestPlanTestCases(request); + } + + + public void editTestCase(TestPlanTestCase testPlanTestCase) { + testPlanTestCase.setUpdateTime(System.currentTimeMillis()); + testPlanTestCaseMapper.updateByPrimaryKeySelective(testPlanTestCase); + } + + public int deleteTestCase(Integer id) { + return testPlanTestCaseMapper.deleteByPrimaryKey(id); + } +} diff --git a/frontend/src/business/components/track/case/components/TestCaseEdit.vue b/frontend/src/business/components/track/case/components/TestCaseEdit.vue index 9f1eabe3d21b148d389f5f2f1100c11c4f1f0dc8..4b745aac3e6a968a53c5d41702755203a96858d1 100644 --- a/frontend/src/business/components/track/case/components/TestCaseEdit.vue +++ b/frontend/src/business/components/track/case/components/TestCaseEdit.vue @@ -63,7 +63,7 @@ - + @@ -306,15 +306,12 @@ .tb-edit .el-input { display: none; - color: black; } .tb-edit .current-row .el-input { display: block; - } .tb-edit .current-row .el-input+span { display: none; - } diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 65178f4739f23a58d3e885d9cc9614169eacd354..d50de6271c551da5dd5de5bde8517ba2f2edc953 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -53,7 +53,7 @@ width="120" show-overflow-tooltip> diff --git a/frontend/src/business/components/track/plan/TestPlanView.vue b/frontend/src/business/components/track/plan/TestPlanView.vue index 0cf31654c1ebf736b22b2ade0e8643bc6dd9710f..c7cbce7efc4e400fd3cb26bc16947751e8c915d4 100644 --- a/frontend/src/business/components/track/plan/TestPlanView.vue +++ b/frontend/src/business/components/track/plan/TestPlanView.vue @@ -24,8 +24,8 @@ ref="testCaseRelevance"> - + ref="testPlanTestCaseEdit" + @refresh="getPlanCases"> @@ -61,7 +61,7 @@ }, getPlanCases(nodeIds) { - this.$refs.testCasePlanList(nodeIds); + this.$refs.testCasePlanList.initTableData(nodeIds); }, openTestCaseRelevanceDialog() { this.$refs.testCaseRelevance.openTestCaseRelevanceDialog(this.planId); @@ -73,8 +73,12 @@ }); } }, - editTestPlanTestCase() { - this.$refs.testPlanTestCaseEdit.drawer = true; + editTestPlanTestCase(testCase) { + let item = {}; + Object.assign(item, testCase); + item.results = JSON.parse(item.results); + this.$refs.testPlanTestCaseEdit.testCase = item; + this.$refs.testPlanTestCaseEdit.dialog = true; } } } diff --git a/frontend/src/business/components/track/plan/components/TestCasePlanList.vue b/frontend/src/business/components/track/plan/components/TestCasePlanList.vue index 978ed7e70880db38a1d94b0d8f301fc79dfe8abe..f027a83e8ed3d25abd404aefec917553f8993e71 100644 --- a/frontend/src/business/components/track/plan/components/TestCasePlanList.vue +++ b/frontend/src/business/components/track/plan/components/TestCasePlanList.vue @@ -53,7 +53,7 @@ width="120" show-overflow-tooltip> @@ -129,7 +129,6 @@