From 04bb963c55035e14b3be78ec064fa0432fa474d3 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Mon, 6 Apr 2020 23:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BC=96=E8=BE=91=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E8=AF=A6=E6=83=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TestCaseController.java | 8 +- .../TestPlanTestCaseController.java | 42 +++++ .../io/metersphere/dto/TestPlanCaseDTO.java | 18 ++ .../metersphere/service/TestCaseService.java | 33 +++- .../service/TestPlanTestCaseService.java | 37 ++++ .../track/case/components/TestCaseEdit.vue | 5 +- .../track/case/components/TestCaseList.vue | 2 +- .../components/track/plan/TestPlanView.vue | 14 +- .../plan/components/TestCasePlanList.vue | 7 +- .../plan/components/TestCaseRelevance.vue | 12 +- .../plan/components/TestPlanTestCaseEdit.vue | 172 ++++++++++++++++-- 11 files changed, 302 insertions(+), 48 deletions(-) create mode 100644 backend/src/main/java/io/metersphere/controller/TestPlanTestCaseController.java create mode 100644 backend/src/main/java/io/metersphere/service/TestPlanTestCaseService.java diff --git a/backend/src/main/java/io/metersphere/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/controller/TestCaseController.java index 673baab94..8f5afee54 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 000000000..d09f9ade9 --- /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 19a725ec8..53a06473b 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 23aa98255..2628be8d9 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 000000000..25edba720 --- /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 9f1eabe3d..4b745aac3 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 65178f473..d50de6271 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 0cf31654c..c7cbce7ef 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 978ed7e70..f027a83e8 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 @@ -- GitLab