From 1dcb1cfe5c1f00c1fbf72856bb27e7178683c14d Mon Sep 17 00:00:00 2001 From: song-cc-rock Date: Wed, 27 Jul 2022 15:38:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E5=9B=9E?= =?UTF-8?q?=E6=94=B6=E7=AB=99=E6=89=B9=E9=87=8F=E6=81=A2=E5=A4=8D=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 --bug=1015435 --user=宋昌昌 [测试跟踪]github#16367回收站选择所有数据,批量恢复用例,每次只恢复10条 https://www.tapd.cn/55049933/s/1213602 --- .../track/service/IssuesService.java | 16 ++++++----- .../track/service/TestCaseService.java | 27 ++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) 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();