diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java new file mode 100644 index 0000000000..a6c9bc9d07 --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.java @@ -0,0 +1,12 @@ +package io.metersphere.base.mapper.ext; + +import io.metersphere.controller.request.ReportRequest; +import io.metersphere.dto.ReportDTO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface ExtLoadTestReportMapper { + + List getReportList(@Param("reportRequest")ReportRequest request); +} diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml new file mode 100644 index 0000000000..bf74baf18a --- /dev/null +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestReportMapper.xml @@ -0,0 +1,16 @@ + + + + + + + \ No newline at end of file diff --git a/backend/src/main/java/io/metersphere/controller/ReportController.java b/backend/src/main/java/io/metersphere/controller/ReportController.java index 93c509f516..ad35d0c6fb 100644 --- a/backend/src/main/java/io/metersphere/controller/ReportController.java +++ b/backend/src/main/java/io/metersphere/controller/ReportController.java @@ -1,17 +1,18 @@ package io.metersphere.controller; +import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import io.metersphere.base.domain.LoadTestReport; import io.metersphere.commons.constants.RoleConstants; +import io.metersphere.commons.utils.PageUtils; +import io.metersphere.commons.utils.Pager; import io.metersphere.controller.request.ReportRequest; +import io.metersphere.dto.ReportDTO; import io.metersphere.service.ReportService; import io.metersphere.user.SessionUtils; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresRoles; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @@ -33,4 +34,15 @@ public class ReportController { PageHelper.startPage(1, count); return reportService.getRecentReportList(request); } + + @PostMapping("/list/all/{goPage}/{pageSize}") + public Pager> getReportList(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody ReportRequest request) { + Page page = PageHelper.startPage(goPage, pageSize, true); + return PageUtils.setPageInfo(page, reportService.getReportList(request)); + } + + @PostMapping("/delete/{reportId}") + public void deleteReport(@PathVariable String reportId) { + reportService.deleteReport(reportId); + } } diff --git a/backend/src/main/java/io/metersphere/controller/request/ReportRequest.java b/backend/src/main/java/io/metersphere/controller/request/ReportRequest.java index ee1246aef4..010ffd0623 100644 --- a/backend/src/main/java/io/metersphere/controller/request/ReportRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/ReportRequest.java @@ -1,6 +1,7 @@ package io.metersphere.controller.request; public class ReportRequest { + private String name; private String workspaceId; public String getWorkspaceId() { @@ -10,4 +11,12 @@ public class ReportRequest { public void setWorkspaceId(String workspaceId) { this.workspaceId = workspaceId; } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } } diff --git a/backend/src/main/java/io/metersphere/dto/ReportDTO.java b/backend/src/main/java/io/metersphere/dto/ReportDTO.java new file mode 100644 index 0000000000..a8a3a3ac7c --- /dev/null +++ b/backend/src/main/java/io/metersphere/dto/ReportDTO.java @@ -0,0 +1,86 @@ +package io.metersphere.dto; + +public class ReportDTO { + + private String id; + private String testId; + private String name; + private String description; + private Long createTime; + private Long updateTime; + private String status; + private String content; + private String testName; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getTestId() { + return testId; + } + + public void setTestId(String testId) { + this.testId = testId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public Long getCreateTime() { + return createTime; + } + + public void setCreateTime(Long createTime) { + this.createTime = createTime; + } + + public Long getUpdateTime() { + return updateTime; + } + + public void setUpdateTime(Long updateTime) { + this.updateTime = updateTime; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public String getTestName() { + return testName; + } + + public void setTestName(String testName) { + this.testName = testName; + } +} diff --git a/backend/src/main/java/io/metersphere/service/ReportService.java b/backend/src/main/java/io/metersphere/service/ReportService.java index 022202bb63..6367992488 100644 --- a/backend/src/main/java/io/metersphere/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/service/ReportService.java @@ -3,7 +3,9 @@ package io.metersphere.service; import io.metersphere.base.domain.LoadTestReport; import io.metersphere.base.domain.LoadTestReportExample; import io.metersphere.base.mapper.LoadTestReportMapper; +import io.metersphere.base.mapper.ext.ExtLoadTestReportMapper; import io.metersphere.controller.request.ReportRequest; +import io.metersphere.dto.ReportDTO; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -16,6 +18,8 @@ public class ReportService { @Resource private LoadTestReportMapper loadTestReportMapper; + @Resource + private ExtLoadTestReportMapper extLoadTestReportMapper; public List getRecentReportList(ReportRequest request) { LoadTestReportExample example = new LoadTestReportExample(); @@ -25,4 +29,12 @@ public class ReportService { example.setOrderByClause("update_time desc"); return loadTestReportMapper.selectByExample(example); } + + public List getReportList(ReportRequest request) { + return extLoadTestReportMapper.getReportList(request); + } + + public void deleteReport(String reportId) { + loadTestReportMapper.deleteByPrimaryKey(reportId); + } } diff --git a/frontend/src/i18n/en-US.js b/frontend/src/i18n/en-US.js index d25ffc7435..2029e89a5a 100644 --- a/frontend/src/i18n/en-US.js +++ b/frontend/src/i18n/en-US.js @@ -89,6 +89,11 @@ export default { role: { 'please_choose_role': 'Please Choose Role', }, + report: { + 'recent': 'Recent Report', + 'search_by_name': 'Search by Name', + 'test_name': 'Test', + }, load_test: { 'recent': 'Recent Tests', 'search_by_name': 'Search by name', diff --git a/frontend/src/i18n/zh-CN.js b/frontend/src/i18n/zh-CN.js index 55d164f5ed..a2d739794d 100644 --- a/frontend/src/i18n/zh-CN.js +++ b/frontend/src/i18n/zh-CN.js @@ -90,6 +90,11 @@ export default { role: { 'please_choose_role': '请选择角色', }, + report: { + 'recent': '最近的报告', + 'search_by_name': '根据名称搜索', + 'test_name': '所属测试', + }, load_test: { 'recent': '最近的测试', 'search_by_name': '根据名称搜索', diff --git a/frontend/src/performance/components/HeaderUser.vue b/frontend/src/performance/components/HeaderUser.vue index c13ff76f30..25c5da52f4 100644 --- a/frontend/src/performance/components/HeaderUser.vue +++ b/frontend/src/performance/components/HeaderUser.vue @@ -135,8 +135,7 @@ changeWs(data) { let sign = "workspace"; let workspaceId = data.id; - // todo 工作空间为空判断 - if (typeof (workspaceId) == "undefined") { + if (!workspaceId) { return false; } this.$post("/user/switch/source/" + sign + "/" + workspaceId, {}, response => { diff --git a/frontend/src/performance/components/report/AllTestReport.vue b/frontend/src/performance/components/report/AllTestReport.vue new file mode 100644 index 0000000000..6ff6903ee7 --- /dev/null +++ b/frontend/src/performance/components/report/AllTestReport.vue @@ -0,0 +1,183 @@ + + + + + diff --git a/frontend/src/performance/components/report/RecentReport.vue b/frontend/src/performance/components/report/RecentReport.vue index 7f1b316034..9eb5b16dea 100644 --- a/frontend/src/performance/components/report/RecentReport.vue +++ b/frontend/src/performance/components/report/RecentReport.vue @@ -1,5 +1,9 @@