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 @@