diff --git a/backend/src/main/java/io/metersphere/track/service/IssuesService.java b/backend/src/main/java/io/metersphere/track/service/IssuesService.java index 4e901822bd..a12a5961cb 100644 --- a/backend/src/main/java/io/metersphere/track/service/IssuesService.java +++ b/backend/src/main/java/io/metersphere/track/service/IssuesService.java @@ -128,13 +128,15 @@ public class IssuesService { attachmentService.copyAttachment(attachmentRequest); } else { // 新增, 需保存并同步所有待上传的附件 - final String issueId = issues.getId(); - files.forEach(file -> { - AttachmentRequest attachmentRequest = new AttachmentRequest(); - attachmentRequest.setBelongId(issueId); - attachmentRequest.setBelongType(AttachmentType.ISSUE.type()); - attachmentService.uploadAttachment(attachmentRequest, file); - }); + if (CollectionUtils.isNotEmpty(files)) { + final String issueId = issues.getId(); + files.forEach(file -> { + AttachmentRequest attachmentRequest = new AttachmentRequest(); + attachmentRequest.setBelongId(issueId); + attachmentRequest.setBelongType(AttachmentType.ISSUE.type()); + attachmentService.uploadAttachment(attachmentRequest, file); + }); + } } return issues; } 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 76f6022f45..3e49cdf5e1 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1968,12 +1968,14 @@ public class TestCaseService { attachmentService.copyAttachment(attachmentRequest); } else { // 新增需上传用例所有待上传的附件 - files.forEach(file -> { - AttachmentRequest attachmentRequest = new AttachmentRequest(); - attachmentRequest.setBelongId(testCaseWithBLOBs.getId()); - attachmentRequest.setBelongType(AttachmentType.TEST_CASE.type()); - attachmentService.uploadAttachment(attachmentRequest, file); - }); + if (CollectionUtils.isNotEmpty(files)) { + files.forEach(file -> { + AttachmentRequest attachmentRequest = new AttachmentRequest(); + attachmentRequest.setBelongId(testCaseWithBLOBs.getId()); + attachmentRequest.setBelongType(AttachmentType.TEST_CASE.type()); + attachmentService.uploadAttachment(attachmentRequest, file); + }); + } } return testCaseWithBLOBs; } @@ -2267,13 +2269,20 @@ public class TestCaseService { } public void reduction(TestCaseBatchRequest request) { - if (CollectionUtils.isNotEmpty(request.getIds())) { - extTestCaseMapper.checkOriginalStatusByIds(request.getIds()); + List ids = new ArrayList<>(); + if (request.getCondition().isSelectAll()) { + List allReductionTestCases = listTestCase(request.getCondition()); + ids = allReductionTestCases.stream().map(TestCaseDTO::getId).collect(Collectors.toList()); + } else { + ids = request.getIds(); + } + if (CollectionUtils.isNotEmpty(ids)) { + extTestCaseMapper.checkOriginalStatusByIds(ids); //检查原来模块是否还在 TestCaseExample example = new TestCaseExample(); // 关联版本之后,必须查询每一个数据的所有版本,依次还原 - example.createCriteria().andIdIn(request.getIds()); + example.createCriteria().andIdIn(ids); List reductionCaseList = testCaseMapper.selectByExample(example); List refIds = reductionCaseList.stream().map(TestCase::getRefId).collect(Collectors.toList()); example.clear();