From 39e3bcddd3e20387809aad223490d0796055ed72 Mon Sep 17 00:00:00 2001 From: "Captain.B" Date: Tue, 11 May 2021 18:55:16 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=80=A7=E8=83=BD=E6=B5=8B=E8=AF=95=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=96=87=E4=BB=B6=E7=9A=84=E6=97=B6=E5=80=99=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=85=B6=E4=BB=96=E6=B5=8B=E8=AF=95=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=BC=95=E7=94=A8=E7=9B=B8=E5=90=8C=E6=96=87=E4=BB=B6=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/PerformanceTestService.java | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java index 4e092f5d34..de809824b7 100644 --- a/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java +++ b/backend/src/main/java/io/metersphere/performance/service/PerformanceTestService.java @@ -222,16 +222,17 @@ public class PerformanceTestService { public String edit(EditTestPlanRequest request, List files) { checkQuota(request, false); // - LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(request.getId()); + String testId = request.getId(); + LoadTestWithBLOBs loadTest = loadTestMapper.selectByPrimaryKey(testId); if (loadTest == null) { - MSException.throwException(Translator.get("edit_load_test_not_found") + request.getId()); + MSException.throwException(Translator.get("edit_load_test_not_found") + testId); } if (StringUtils.containsAny(loadTest.getStatus(), PerformanceTestStatus.Running.name(), PerformanceTestStatus.Starting.name())) { MSException.throwException(Translator.get("cannot_edit_load_test_running")); } // 新选择了一个文件,删除原来的文件 List updatedFiles = request.getUpdatedFileList(); - List originFiles = getFileMetadataByTestId(request.getId()); + List originFiles = getFileMetadataByTestId(testId); List updatedFileIds = updatedFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); List originFileIds = originFiles.stream().map(FileMetadata::getId).collect(Collectors.toList()); @@ -240,13 +241,15 @@ public class PerformanceTestService { // 删除已经不相关的文件 if (!CollectionUtils.isEmpty(deleteFileIds)) { LoadTestFileExample example3 = new LoadTestFileExample(); - example3.createCriteria().andFileIdIn(deleteFileIds); + example3.createCriteria() + .andFileIdIn(deleteFileIds) + .andTestIdEqualTo(testId); loadTestFileMapper.deleteByExample(example3); } // 导入项目里其他的文件 List addFileIds = ListUtils.subtract(updatedFileIds, originFileIds); - this.importFiles(addFileIds, request.getId(), request.getFileSorts()); + this.importFiles(addFileIds, testId, request.getFileSorts()); // 处理新上传的文件 this.saveUploadFiles(files, loadTest, request.getFileSorts()); @@ -260,7 +263,7 @@ public class PerformanceTestService { loadTest.setStatus(PerformanceTestStatus.Saved.name()); loadTestMapper.updateByPrimaryKeySelective(loadTest); - return request.getId(); + return testId; } @Transactional(noRollbackFor = MSException.class)// 保存失败的信息