diff --git a/backend/src/main/java/io/metersphere/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/controller/TestCaseController.java index 56f6820d29..be6de35cfd 100644 --- a/backend/src/main/java/io/metersphere/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/controller/TestCaseController.java @@ -53,7 +53,7 @@ public class TestCaseController { return testCaseService.getTestCaseNames(request); } - @PostMapping("/get/{testCaseId}") + @GetMapping("/get/{testCaseId}") public List getTestCase(@PathVariable String testCaseId){ return testCaseService.getTestCase(testCaseId); } diff --git a/backend/src/main/java/io/metersphere/controller/TestPlanController.java b/backend/src/main/java/io/metersphere/controller/TestPlanController.java index 9767bd8798..9379f02ea4 100644 --- a/backend/src/main/java/io/metersphere/controller/TestPlanController.java +++ b/backend/src/main/java/io/metersphere/controller/TestPlanController.java @@ -8,10 +8,12 @@ import io.metersphere.base.domain.TestPlan; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.controller.request.testcase.PlanCaseRelevanceRequest; +import io.metersphere.controller.request.testcase.QueryTestCaseRequest; import io.metersphere.controller.request.testcase.QueryTestPlanRequest; import io.metersphere.dto.TestPlanDTO; import io.metersphere.service.TestCaseService; import io.metersphere.service.TestPlanService; +import io.metersphere.user.SessionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -30,6 +32,14 @@ public class TestPlanController { return PageUtils.setPageInfo(page, testPlanService.listTestPlan(request)); } + + @GetMapping("recent/{count}") + public List recentTestPlans(@PathVariable int count) { + String currentWorkspaceId = SessionUtils.getCurrentWorkspaceId(); + PageHelper.startPage(1, count, true); + return testPlanService.recentTestPlans(currentWorkspaceId); + } + @PostMapping("/get/{testPlanId}") public List getTestPlan(@PathVariable String testPlanId){ return testPlanService.getTestPlan(testPlanId); diff --git a/backend/src/main/java/io/metersphere/service/TestCaseService.java b/backend/src/main/java/io/metersphere/service/TestCaseService.java index 0cb5a197cc..704e4c20ff 100644 --- a/backend/src/main/java/io/metersphere/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/service/TestCaseService.java @@ -2,6 +2,7 @@ package io.metersphere.service; import io.metersphere.base.domain.*; +import io.metersphere.base.mapper.ProjectMapper; import io.metersphere.base.mapper.TestCaseMapper; import io.metersphere.base.mapper.TestPlanMapper; import io.metersphere.base.mapper.TestPlanTestCaseMapper; @@ -36,6 +37,9 @@ public class TestCaseService { @Resource TestPlanTestCaseMapper testPlanTestCaseMapper; + @Resource + ProjectMapper projectMapper; + public void addTestCase(TestCaseWithBLOBs testCase) { testCase.setId(UUID.randomUUID().toString()); testCase.setCreateTime(System.currentTimeMillis()); @@ -111,6 +115,20 @@ public class TestCaseService { public List recentTestPlans(QueryTestCaseRequest request) { - return null; + + if (StringUtils.isBlank(request.getWorkspaceId())) { + return null; + } + + ProjectExample projectExample = new ProjectExample(); + projectExample.createCriteria().andWorkspaceIdEqualTo(request.getWorkspaceId()); + + List projectIds = projectMapper.selectByExample(projectExample).stream() + .map(Project::getId).collect(Collectors.toList()); + + TestCaseExample testCaseExample = new TestCaseExample(); + testCaseExample.createCriteria().andProjectIdIn(projectIds); + testCaseExample.setOrderByClause("update_time desc"); + return testCaseMapper.selectByExample(testCaseExample); } } diff --git a/backend/src/main/java/io/metersphere/service/TestPlanService.java b/backend/src/main/java/io/metersphere/service/TestPlanService.java index 140598d919..338876fdbe 100644 --- a/backend/src/main/java/io/metersphere/service/TestPlanService.java +++ b/backend/src/main/java/io/metersphere/service/TestPlanService.java @@ -101,4 +101,14 @@ public class TestPlanService { sqlSession.flushStatements(); } + + public List recentTestPlans(String currentWorkspaceId) { + if (StringUtils.isBlank(currentWorkspaceId)) { + return null; + } + TestPlanExample testPlanTestCaseExample = new TestPlanExample(); + testPlanTestCaseExample.createCriteria().andWorkspaceIdEqualTo(currentWorkspaceId); + testPlanTestCaseExample.setOrderByClause("update_time desc"); + return testPlanMapper.selectByExample(testPlanTestCaseExample); + } } diff --git a/frontend/src/business/components/common/router/router.js b/frontend/src/business/components/common/router/router.js index 339efbf51c..0dac4ad4af 100644 --- a/frontend/src/business/components/common/router/router.js +++ b/frontend/src/business/components/common/router/router.js @@ -204,10 +204,15 @@ const router = new VueRouter({ component: TrackHome, }, { - path: 'case/:caseId', + path: 'case/:projectId', name: 'testCase', component: TestCase, }, + { + path: 'case/edit/:caseId', + name: 'testCaseEdit', + component: TestCase, + }, { path: "plan/:projectId", name: "testPlan", diff --git a/frontend/src/business/components/track/case/TestCase.vue b/frontend/src/business/components/track/case/TestCase.vue index 17797910d0..a710820368 100644 --- a/frontend/src/business/components/track/case/TestCase.vue +++ b/frontend/src/business/components/track/case/TestCase.vue @@ -22,8 +22,8 @@ @@ -39,7 +39,7 @@ @@ -73,13 +73,22 @@ } }, created: function () { - this.projectId = this.$route.params.projectId; + this.caseId = this.$route.params.caseId; this.getProjects(); }, watch: { '$route'(to, from) { - if (from.name.indexOf("Project") >= 0){ + let path = to.path; + if (path.indexOf("/track/case/all") >= 0){ this.getProjects(); + this.refresh(); + } + if (path.indexOf("/track/case/edit") >= 0){ + let caseId = this.$route.params.caseId; + this.$get('/test/case/get/' + caseId, response => { + console.log(response.data); + this.openTestCaseEditDialog(response.data[0]); + }); } } }, @@ -120,10 +129,10 @@ changeProject(project) { this.currentProject = project; localStorage.setItem(CURRENT_PROJECT, JSON.stringify(project)); - this.$refs.testCaseList.initTableData() + this.$refs.testCaseList.initTableData(); this.$refs.nodeTree.getNodeTree(); }, - getCaseByNodeIds(data) { + refreshTable(data) { this.$refs.testCaseList.initTableData(data); }, openTestCaseEditDialog(data) { @@ -154,6 +163,10 @@ this.$post('/user/ws/member/list/all', {workspaceId:workspaceId}, response => { this.$refs.testCaseEditDialog.maintainerOptions = response.data; }); + }, + refresh() { + this.$refs.testCaseList.initTableData(); + this.$refs.nodeTree.getNodeTree(); } } } diff --git a/frontend/src/business/components/track/case/components/RecentTestCase.vue b/frontend/src/business/components/track/case/components/RecentTestCase.vue index f2dc105c98..4fb0801186 100644 --- a/frontend/src/business/components/track/case/components/RecentTestCase.vue +++ b/frontend/src/business/components/track/case/components/RecentTestCase.vue @@ -4,7 +4,8 @@ {{$t('load_test.recent')}} - + {{ t.name }} @@ -20,14 +21,14 @@ const roles = rolesString.split(','); if (roles.indexOf(ROLE_TEST_MANAGER) > -1 || roles.indexOf(ROLE_TEST_USER) > -1 || roles.indexOf(ROLE_TEST_VIEWER) > -1) { - this.$get('/performance/recent/5', (response) => { - this.recentTestPlans = response.data; + this.$get('/test/case/recent/5', (response) => { + this.recentTestCases = response.data; }); } }, data() { return { - recentTestPlans: [] + recentTestCases: [] } } } diff --git a/frontend/src/business/components/track/head/HeaderMenus.vue b/frontend/src/business/components/track/head/HeaderMenus.vue index c831c362fa..e369843201 100644 --- a/frontend/src/business/components/track/head/HeaderMenus.vue +++ b/frontend/src/business/components/track/head/HeaderMenus.vue @@ -38,6 +38,7 @@ + @@ -58,10 +59,11 @@ import {checkoutCurrentWorkspace} from "../../../../common/utils"; import TrackRecentProject from "../../track/project/TrackRecentProject"; import RecentTestCase from "../case/components/RecentTestCase"; + import RecentTestPlan from "../plan/components/RecentTestPlan"; export default { name: "MsMenus", - components: {RecentTestCase, TrackRecentProject }, + components: {RecentTestCase, TrackRecentProject, RecentTestPlan}, data() { return { isCurrentWorkspaceUser: false, diff --git a/frontend/src/business/components/track/plan/components/RecentTestPlan.vue b/frontend/src/business/components/track/plan/components/RecentTestPlan.vue new file mode 100644 index 0000000000..8dfff4e1b2 --- /dev/null +++ b/frontend/src/business/components/track/plan/components/RecentTestPlan.vue @@ -0,0 +1,42 @@ + + + + +