From bb7d818a334a42e91b79706e704c0881dd48fb06 Mon Sep 17 00:00:00 2001 From: q4speed Date: Mon, 18 May 2020 15:32:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=B5=8B=E8=AF=95=E5=85=B3?= =?UTF-8?q?=E8=81=94=E6=8A=A5=E5=91=8A=E6=9F=A5=E8=AF=A2=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84bug=20=E9=A6=96=E9=A1=B5=E5=A2=9E=E5=8A=A0=E6=B5=8B?= =?UTF-8?q?=E8=AF=95=E6=97=A5=E5=8E=86=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/controller/APIReportController.java | 13 +++++++++ .../api/service/APIReportService.java | 10 +++++++ .../mapper/ext/ExtApiTestReportMapper.java | 3 ++ .../mapper/ext/ExtApiTestReportMapper.xml | 14 +++++++++- .../components/api/home/ApiTestHome.vue | 28 +++++++++++++++++-- .../components/api/test/ApiReportDialog.vue | 7 +++-- .../components/api/test/ApiTestConfig.vue | 2 +- 7 files changed, 71 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/controller/APIReportController.java b/backend/src/main/java/io/metersphere/api/controller/APIReportController.java index b3ed90540c..75d36a1fc2 100644 --- a/backend/src/main/java/io/metersphere/api/controller/APIReportController.java +++ b/backend/src/main/java/io/metersphere/api/controller/APIReportController.java @@ -10,11 +10,13 @@ import io.metersphere.commons.constants.RoleConstants; import io.metersphere.commons.utils.PageUtils; import io.metersphere.commons.utils.Pager; import io.metersphere.commons.utils.SessionUtils; +import io.metersphere.dto.DashboardTestDTO; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresRoles; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; + import java.util.List; @RestController @@ -34,6 +36,11 @@ public class APIReportController { return apiReportService.recentTest(request); } + @GetMapping("/list/{testId}") + public List listByTestId(@PathVariable String testId) { + return apiReportService.listByTestId(testId); + } + @PostMapping("/list/{goPage}/{pageSize}") public Pager> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryAPIReportRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); @@ -51,4 +58,10 @@ public class APIReportController { apiReportService.delete(request); } + @GetMapping("dashboard/tests") + public List dashboardTests() { + return apiReportService.dashboardTests(SessionUtils.getCurrentWorkspaceId()); + } + + } diff --git a/backend/src/main/java/io/metersphere/api/service/APIReportService.java b/backend/src/main/java/io/metersphere/api/service/APIReportService.java index 86ed339a3a..837f6cfe59 100644 --- a/backend/src/main/java/io/metersphere/api/service/APIReportService.java +++ b/backend/src/main/java/io/metersphere/api/service/APIReportService.java @@ -10,9 +10,12 @@ import io.metersphere.base.domain.ApiTestWithBLOBs; import io.metersphere.base.mapper.ApiTestReportMapper; import io.metersphere.base.mapper.ext.ExtApiTestReportMapper; import io.metersphere.commons.constants.APITestStatus; +import io.metersphere.dto.DashboardTestDTO; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.time.Instant; +import java.time.temporal.ChronoUnit; import java.util.List; import java.util.UUID; @@ -62,4 +65,11 @@ public class APIReportService { report.setStatus(APITestStatus.Completed.name()); apiTestReportMapper.insert(report); } + + + public List dashboardTests(String workspaceId) { + Instant oneYearAgo = Instant.now().plus(-365, ChronoUnit.DAYS); + long startTimestamp = oneYearAgo.toEpochMilli(); + return extApiTestReportMapper.selectDashboardTests(workspaceId, startTimestamp); + } } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.java index c03c871e5f..2e702edfe1 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.java @@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.api.dto.APIReportResult; import io.metersphere.api.dto.QueryAPIReportRequest; import io.metersphere.dto.ApiReportDTO; +import io.metersphere.dto.DashboardTestDTO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -15,4 +16,6 @@ public interface ExtApiTestReportMapper { APIReportResult get(@Param("id") String id); + List selectDashboardTests(@Param("workspaceId") String workspaceId, @Param("startTimestamp") long startTimestamp); + } diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml index 796e05f441..486cd87548 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtApiTestReportMapper.xml @@ -29,7 +29,7 @@ + + \ No newline at end of file diff --git a/frontend/src/business/components/api/home/ApiTestHome.vue b/frontend/src/business/components/api/home/ApiTestHome.vue index 27eaf8292b..18175a0cdb 100644 --- a/frontend/src/business/components/api/home/ApiTestHome.vue +++ b/frontend/src/business/components/api/home/ApiTestHome.vue @@ -1,6 +1,6 @@