From 11956de1ea73d9626d212e0963b7b2e58070e985 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 8 Apr 2020 15:42:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=90=E9=A1=B5=E9=9D=A2=E6=BF=80=E6=B4=BB?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/TestCaseController.java | 13 +++--- .../metersphere/service/TestCaseService.java | 13 +++++- .../src/business/components/api/ApiTest.vue | 6 +-- .../{HeaderMenus.vue => ApiHeaderMenus.vue} | 44 ++++++++++++++++-- .../performance/PerformanceTest.vue | 6 +-- ...erMenus.vue => PerformanceHeaderMenus.vue} | 46 ++++++++++++++++--- .../business/components/track/TestTrack.vue | 6 +-- .../components/track/case/TestCase.vue | 30 ++++++++---- .../track/case/components/TestCaseList.vue | 1 - .../{HeaderMenus.vue => TrackHeaderMenus.vue} | 43 +++++++++++++---- 10 files changed, 165 insertions(+), 43 deletions(-) rename frontend/src/business/components/api/head/{HeaderMenus.vue => ApiHeaderMenus.vue} (71%) rename frontend/src/business/components/performance/head/{HeaderMenus.vue => PerformanceHeaderMenus.vue} (73%) rename frontend/src/business/components/track/head/{HeaderMenus.vue => TrackHeaderMenus.vue} (75%) diff --git a/backend/src/main/java/io/metersphere/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/controller/TestCaseController.java index be6de35cfd..f5a8bb4ac2 100644 --- a/backend/src/main/java/io/metersphere/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/controller/TestCaseController.java @@ -2,10 +2,7 @@ package io.metersphere.controller; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; -import io.metersphere.base.domain.LoadTest; -import io.metersphere.base.domain.TestCase; -import io.metersphere.base.domain.TestCaseNode; -import io.metersphere.base.domain.TestCaseWithBLOBs; +import io.metersphere.base.domain.*; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.controller.request.testcase.QueryTestCaseRequest; @@ -39,8 +36,7 @@ public class TestCaseController { String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); QueryTestCaseRequest request = new QueryTestCaseRequest(); request.setWorkspaceId(currentWorkspaceId); - PageHelper.startPage(1, count, true); - return testCaseService.recentTestPlans(request); + return testCaseService.recentTestPlans(request, count); } @PostMapping("/list") @@ -58,6 +54,11 @@ public class TestCaseController { return testCaseService.getTestCase(testCaseId); } + @GetMapping("/project/{testCaseId}") + public Project getProjectByTestCaseId(@PathVariable String testCaseId){ + return testCaseService.getProjectByTestCaseId(testCaseId); + } + @PostMapping("/add") public void addTestCase(@RequestBody TestCaseWithBLOBs testCase){ testCaseService.addTestCase(testCase); diff --git a/backend/src/main/java/io/metersphere/service/TestCaseService.java b/backend/src/main/java/io/metersphere/service/TestCaseService.java index 704e4c20ff..f87685b67c 100644 --- a/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -1,6 +1,7 @@ package io.metersphere.service; +import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.*; import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.TestCaseMapper; @@ -114,7 +115,7 @@ public class TestCaseService { } - public List recentTestPlans(QueryTestCaseRequest request) { + public List recentTestPlans(QueryTestCaseRequest request, int count) { if (StringUtils.isBlank(request.getWorkspaceId())) { return null; @@ -126,9 +127,19 @@ public class TestCaseService { List projectIds = projectMapper.selectByExample(projectExample).stream() .map(Project::getId).collect(Collectors.toList()); + PageHelper.startPage(1, count, true); + TestCaseExample testCaseExample = new TestCaseExample(); testCaseExample.createCriteria().andProjectIdIn(projectIds); testCaseExample.setOrderByClause("update_time desc"); return testCaseMapper.selectByExample(testCaseExample); } + + public Project getProjectByTestCaseId(String testCaseId) { + TestCaseWithBLOBs testCaseWithBLOBs = testCaseMapper.selectByPrimaryKey(testCaseId); + if (testCaseWithBLOBs == null) { + return null; + } + return projectMapper.selectByPrimaryKey(testCaseWithBLOBs.getProjectId()); + } } diff --git a/frontend/src/business/components/api/ApiTest.vue b/frontend/src/business/components/api/ApiTest.vue index 7246cf7d34..84210b9103 100644 --- a/frontend/src/business/components/api/ApiTest.vue +++ b/frontend/src/business/components/api/ApiTest.vue @@ -1,6 +1,6 @@ +