diff --git a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml index 946015b527..7a0f7273c4 100644 --- a/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml +++ b/backend/src/main/java/io/metersphere/base/mapper/ext/ExtLoadTestMapper.xml @@ -15,6 +15,9 @@ and load_test.name like CONCAT('%', #{request.name},'%') + + AND project.workspace_id = #{request.workspaceId} + diff --git a/backend/src/main/java/io/metersphere/controller/LoadTestController.java b/backend/src/main/java/io/metersphere/controller/LoadTestController.java index 9e99fcb198..a30a1a736d 100644 --- a/backend/src/main/java/io/metersphere/controller/LoadTestController.java +++ b/backend/src/main/java/io/metersphere/controller/LoadTestController.java @@ -9,6 +9,7 @@ import io.metersphere.controller.request.testplan.*; import io.metersphere.dto.LoadTestDTO; import io.metersphere.service.FileService; import io.metersphere.service.LoadTestService; +import io.metersphere.user.SessionUtils; import org.springframework.http.HttpHeaders; import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; @@ -29,6 +30,7 @@ public class LoadTestController { @PostMapping("/list/{goPage}/{pageSize}") public Pager> list(@PathVariable int goPage, @PathVariable int pageSize, @RequestBody QueryTestPlanRequest request) { Page page = PageHelper.startPage(goPage, pageSize, true); + request.setWorkspaceId(SessionUtils.getCurrentWorkspaceId()); return PageUtils.setPageInfo(page, loadTestService.list(request)); } @@ -64,12 +66,11 @@ public class LoadTestController { } @PostMapping("/file/download") - public ResponseEntity downloadJmx(@RequestBody FileOperationRequest fileOperationRequest) { - org.springframework.core.io.Resource resource = fileService.loadFileAsResource(fileOperationRequest.getName()); - + public ResponseEntity downloadJmx(@RequestBody FileOperationRequest fileOperationRequest) { + byte[] bytes = fileService.loadFileAsBytes(fileOperationRequest.getId()); return ResponseEntity.ok() .contentType(MediaType.parseMediaType("application/octet-stream")) .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + fileOperationRequest.getName() + "\"") - .body(resource); + .body(bytes); } } diff --git a/backend/src/main/java/io/metersphere/controller/request/testplan/FileOperationRequest.java b/backend/src/main/java/io/metersphere/controller/request/testplan/FileOperationRequest.java index 98e8c0ae5b..20853dc30b 100644 --- a/backend/src/main/java/io/metersphere/controller/request/testplan/FileOperationRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/testplan/FileOperationRequest.java @@ -1,8 +1,17 @@ package io.metersphere.controller.request.testplan; public class FileOperationRequest { + private String id; private String name; + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + public String getName() { return name; } diff --git a/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java b/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java index 263690c957..62859dfc4e 100644 --- a/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java +++ b/backend/src/main/java/io/metersphere/controller/request/testplan/QueryTestPlanRequest.java @@ -2,6 +2,7 @@ package io.metersphere.controller.request.testplan; public class QueryTestPlanRequest extends TestPlanRequest { private String name; + private String workspaceId; @Override public String getName() { @@ -12,4 +13,12 @@ public class QueryTestPlanRequest extends TestPlanRequest { public void setName(String name) { this.name = name; } + + public String getWorkspaceId() { + return workspaceId; + } + + public void setWorkspaceId(String workspaceId) { + this.workspaceId = workspaceId; + } } diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java index d30a2eab51..dd718be1e0 100644 --- a/backend/src/main/java/io/metersphere/service/FileService.java +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -38,18 +38,10 @@ public class FileService { fileMap.put(name, file); } - public org.springframework.core.io.Resource loadFileAsResource(String name) { - final MultipartFile file = fileMap.get(name); + public byte[] loadFileAsBytes(String id) { + FileContent fileContent = fileContentMapper.selectByPrimaryKey(id); - if (file != null) { - try { - return new InputStreamResource(file.getInputStream()); - } catch (IOException e) { - e.printStackTrace(); - } - } - - return null; + return fileContent.getFile(); } public FileMetadata getFileMetadataByTestId(String testId) { diff --git a/frontend/src/performance/components/testPlan/components/BasicConfig.vue b/frontend/src/performance/components/testPlan/components/BasicConfig.vue index 8730fd8ab2..b915341b43 100644 --- a/frontend/src/performance/components/testPlan/components/BasicConfig.vue +++ b/frontend/src/performance/components/testPlan/components/BasicConfig.vue @@ -53,7 +53,7 @@