diff --git a/backend/src/main/java/io/metersphere/controller/ProjectController.java b/backend/src/main/java/io/metersphere/controller/ProjectController.java index 1711633b9b..f9feec4b15 100644 --- a/backend/src/main/java/io/metersphere/controller/ProjectController.java +++ b/backend/src/main/java/io/metersphere/controller/ProjectController.java @@ -88,7 +88,12 @@ public class ProjectController { @PostMapping(value = "upload/files/{projectId}", consumes = {"multipart/form-data"}) public List uploadFiles(@PathVariable String projectId, @RequestPart(value = "file") List files) { - return projectService.uploadFiles(projectId, files); + return projectService.uploadFiles(projectId, files); + } + + @PostMapping(value = "/update/file/{projectId}/{fileId}", consumes = {"multipart/form-data"}) + public FileMetadata updateFile(@PathVariable String projectId, @PathVariable String fileId, @RequestPart(value = "file") MultipartFile file) { + return projectService.updateFile(projectId, fileId, file); } @GetMapping(value = "delete/file/{fileId}") diff --git a/backend/src/main/java/io/metersphere/service/FileService.java b/backend/src/main/java/io/metersphere/service/FileService.java index cc2aa106c2..817ca5826d 100644 --- a/backend/src/main/java/io/metersphere/service/FileService.java +++ b/backend/src/main/java/io/metersphere/service/FileService.java @@ -73,9 +73,13 @@ public class FileService { fileContentMapper.deleteByExample(example2); } - public FileMetadata saveFile(MultipartFile file, String projectId) { + public FileMetadata saveFile(MultipartFile file, String projectId, String fileId) { final FileMetadata fileMetadata = new FileMetadata(); - fileMetadata.setId(UUID.randomUUID().toString()); + if (StringUtils.isEmpty(fileId)) { + fileMetadata.setId(UUID.randomUUID().toString()); + } else { + fileMetadata.setId(fileId); + } fileMetadata.setName(file.getOriginalFilename()); fileMetadata.setSize(file.getSize()); fileMetadata.setProjectId(projectId); @@ -97,6 +101,10 @@ public class FileService { return fileMetadata; } + public FileMetadata saveFile(MultipartFile file, String projectId) { + return saveFile(file, projectId, null); + } + public FileMetadata saveFile(MultipartFile file) { return saveFile(file, null); } @@ -205,7 +213,7 @@ public class FileService { if (!StringUtils.isEmpty(request.getName())) { criteria.andNameEqualTo(request.getName()); } - return fileMetadataMapper.selectByExample(example); + return fileMetadataMapper.selectByExample(example); } public List getFileMetadataByIds(List fileIds) { diff --git a/backend/src/main/java/io/metersphere/service/ProjectService.java b/backend/src/main/java/io/metersphere/service/ProjectService.java index 4723f29dc3..7fea391b86 100644 --- a/backend/src/main/java/io/metersphere/service/ProjectService.java +++ b/backend/src/main/java/io/metersphere/service/ProjectService.java @@ -186,6 +186,18 @@ public class ProjectService { return result; } + public FileMetadata updateFile(String projectId, String fileId, MultipartFile file) { + QueryProjectFileRequest request = new QueryProjectFileRequest(); + request.setName(file.getOriginalFilename()); + if (CollectionUtils.isEmpty(fileService.getProjectFiles(projectId, request))) { + fileService.deleteFileById(fileId); + return fileService.saveFile(file, projectId); + } else { + MSException.throwException(Translator.get("project_file_already_exists")); + } + return null; + } + public void deleteFile(String fileId) { LoadTestFileExample example1 = new LoadTestFileExample(); example1.createCriteria().andFileIdEqualTo(fileId); @@ -216,4 +228,5 @@ public class ProjectService { } fileService.deleteFileById(fileId); } + } diff --git a/backend/src/main/resources/db/migration/V78__v1.8_release.sql b/backend/src/main/resources/db/migration/V78__v1.8_release.sql index 052e96d640..afe34f84b3 100644 --- a/backend/src/main/resources/db/migration/V78__v1.8_release.sql +++ b/backend/src/main/resources/db/migration/V78__v1.8_release.sql @@ -206,7 +206,9 @@ create table system_header ( type varchar(150) null, props varchar(1000) null -); + +)ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4; -- init system_header insert into system_header (type, props) values ('api_scenario_list', diff --git a/backend/src/main/resources/mail/ApiFailedNotification.html b/backend/src/main/resources/mail/ApiFailedNotification.html index 19911bbdf8..0eae4dc441 100644 --- a/backend/src/main/resources/mail/ApiFailedNotification.html +++ b/backend/src/main/resources/mail/ApiFailedNotification.html @@ -11,8 +11,7 @@

您好:

- successContext = "接口测试定时任务通知:'" + report.getName() + "'执行成功" + "\n" + "【接口定义暂无报告链接】"+"\n" +"请点击下面链接进入测试报告页面" + - "\n" + "(旧版)接口测试路径" + url + "\n" + "(新版)接口测试路径" + url2; +

您所执行的 ${testName} 接口测试运行失败
请点击下面链接进入测试报告页面【接口定义暂无报告路径】
diff --git a/frontend/src/business/components/performance/test/components/ResourceFiles.vue b/frontend/src/business/components/performance/test/components/ResourceFiles.vue index 5e26e276f2..b05920888b 100644 --- a/frontend/src/business/components/performance/test/components/ResourceFiles.vue +++ b/frontend/src/business/components/performance/test/components/ResourceFiles.vue @@ -16,7 +16,7 @@ :before-upload="beforeUploadFile" :http-request="handleUpload" :on-exceed="handleExceed" - :file-list="fileList"> + > @@ -46,6 +46,23 @@