diff --git a/Dockerfile b/Dockerfile index 16209e91ab..705770d659 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,11 +6,11 @@ ARG MS_VERSION=dev RUN mkdir -p /opt/apps && mkdir -p /opt/jmeter -ADD backend/target/backend-1.0.jar /opt/apps +ADD backend/target/backend-1.1.jar /opt/apps ADD backend/target/classes/jmeter/ /opt/jmeter/ -ENV JAVA_APP_JAR=/opt/apps/backend-1.0.jar +ENV JAVA_APP_JAR=/opt/apps/backend-1.1.jar ENV AB_OFF=true diff --git a/backend/pom.xml b/backend/pom.xml index a5ba9df9a0..430247e92e 100644 --- a/backend/pom.xml +++ b/backend/pom.xml @@ -7,7 +7,7 @@ metersphere-server io.metersphere - 1.0 + 1.1 4.0.0 @@ -376,4 +376,4 @@ https://maven.pkg.github.com/metersphere/jmeter-plugins-for-apache-dubbo - \ No newline at end of file + diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java index 7ad9f0e5aa..6c3461bf73 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.java @@ -3,6 +3,7 @@ package io.metersphere.base.mapper.ext; import io.metersphere.base.domain.TestCase; import io.metersphere.track.request.testcase.QueryTestCaseRequest; import io.metersphere.track.dto.TestCaseDTO; +import io.metersphere.track.request.testcase.TestCaseBatchRequest; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -15,7 +16,7 @@ public interface ExtTestCaseMapper { List listByMethod(@Param("request") QueryTestCaseRequest request); - List listBytestCaseIds(@Param("request") QueryTestCaseRequest request); + List listBytestCaseIds(@Param("request") TestCaseBatchRequest request); TestCase getMaxNumByProjectId(@Param("projectId") String projectId); diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml index 7d02963964..8949c82d2f 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtTestCaseMapper.xml @@ -202,9 +202,9 @@ select test_case.*,api_test.name as apiName,load_test.name AS performName from test_case left join api_test on test_case.test_id=api_test.id left join load_test on test_case.test_id=load_test.id - + and test_case.id in - + #{id} diff --git a/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java b/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java index b3d806ef85..178b6304f6 100644 --- a/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java +++ b/backend/src/main/java/io/metersphere/performance/controller/PerformanceReportController.java @@ -15,12 +15,11 @@ import io.metersphere.performance.controller.request.ReportRequest; import io.metersphere.performance.service.ReportService; import org.apache.shiro.authz.annotation.Logical; import org.apache.shiro.authz.annotation.RequiresRoles; -import org.springframework.http.HttpHeaders; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; import java.util.List; @RestController @@ -112,11 +111,15 @@ public class PerformanceReportController { } @GetMapping("log/download/{reportId}/{resourceId}") - public ResponseEntity downloadLog(@PathVariable String reportId, @PathVariable String resourceId) { - byte[] bytes = reportService.downloadLog(reportId, resourceId); - return ResponseEntity.ok() - .contentType(MediaType.parseMediaType("application/octet-stream")) - .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"jmeter.log\"") - .body(bytes); + public void downloadLog(@PathVariable String reportId, @PathVariable String resourceId, HttpServletResponse response) throws Exception { + try (OutputStream outputStream = response.getOutputStream()) { + List content = reportService.downloadLog(reportId, resourceId); + response.setContentType("application/x-download"); + response.addHeader("Content-Disposition", "attachment;filename=jmeter.log"); + for (String log : content) { + outputStream.write(log.getBytes()); + } + outputStream.flush(); + } } } diff --git a/backend/src/main/java/io/metersphere/performance/service/ReportService.java b/backend/src/main/java/io/metersphere/performance/service/ReportService.java index 96bde66a53..ff5ec96f9e 100644 --- a/backend/src/main/java/io/metersphere/performance/service/ReportService.java +++ b/backend/src/main/java/io/metersphere/performance/service/ReportService.java @@ -25,6 +25,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; @Service @Transactional(rollbackFor = Exception.class) @@ -210,14 +211,13 @@ public class ReportService { return loadTestReportLogMapper.selectByExampleWithBLOBs(example); } - public byte[] downloadLog(String reportId, String resourceId) { + public List downloadLog(String reportId, String resourceId) { LoadTestReportLogExample example = new LoadTestReportLogExample(); example.createCriteria().andReportIdEqualTo(reportId).andResourceIdEqualTo(resourceId); example.setOrderByClause("part desc"); List loadTestReportLogs = loadTestReportLogMapper.selectByExampleWithBLOBs(example); - String content = loadTestReportLogs.stream().map(LoadTestReportLog::getContent).reduce("", (a, b) -> a + b); - return content.getBytes(); + return loadTestReportLogs.stream().map(LoadTestReportLog::getContent).collect(Collectors.toList()); } public LoadTestReport getReport(String reportId) { diff --git a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java index b6b519c0ae..d3a79acb54 100644 --- a/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java +++ b/backend/src/main/java/io/metersphere/track/controller/TestCaseController.java @@ -110,9 +110,9 @@ public class TestCaseController { public void testCaseTemplateExport(HttpServletResponse response){ testCaseService.testCaseTemplateExport(response); } - @GetMapping("/export/testCase/{testCaseIds}") + @PostMapping("/export/testcase") @RequiresRoles(value = {RoleConstants.TEST_USER, RoleConstants.TEST_MANAGER}, logical = Logical.OR) - public void testCaseExport(HttpServletResponse response,QueryTestCaseRequest request){ + public void testCaseExport( HttpServletResponse response,@RequestBody TestCaseBatchRequest request){ testCaseService.testCaseExport(response,request); } diff --git a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java index 477fc7eb7a..a2e3d6040f 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -310,7 +310,7 @@ public class TestCaseService { return list; } - public void testCaseExport(HttpServletResponse response, QueryTestCaseRequest request) { + public void testCaseExport(HttpServletResponse response, TestCaseBatchRequest request) { EasyExcelExporter easyExcelExporter = null; try { easyExcelExporter = new EasyExcelExporter(TestCaseExcelData.class); @@ -323,7 +323,7 @@ public class TestCaseService { } } - private List generateTestCaseExcel(QueryTestCaseRequest request) { + private List generateTestCaseExcel(TestCaseBatchRequest request) { List TestCaseList = extTestCaseMapper.listBytestCaseIds(request); List list = new ArrayList<>(); SessionUser user = SessionUtils.getUser(); diff --git a/frontend/pom.xml b/frontend/pom.xml index e78f03d58c..fad8d9c5c0 100644 --- a/frontend/pom.xml +++ b/frontend/pom.xml @@ -7,7 +7,7 @@ metersphere-server io.metersphere - 1.0 + 1.1 4.0.0 diff --git a/frontend/src/business/components/track/case/components/TestCaseList.vue b/frontend/src/business/components/track/case/components/TestCaseList.vue index 2bcc6ed782..d36227613a 100644 --- a/frontend/src/business/components/track/case/components/TestCaseList.vue +++ b/frontend/src/business/components/track/case/components/TestCaseList.vue @@ -292,9 +292,10 @@ }, exportTestCase() { let config = { - url: '/test/case/export/testCase/' + [...this.selectIds], - method: 'get', - responseType: 'blob' + url: '/test/case/export/testcase', + method: 'post', + responseType: 'blob', + data: {ids: [...this.selectIds]} }; this.result = this.$request(config).then(response => { const filename = this.$t('test_track.case.test_case') + ".xlsx"; diff --git a/pom.xml b/pom.xml index 7277be513f..d6a5c89a3e 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.metersphere metersphere-server - 1.0 + 1.1 pom