fix(测试跟踪): 修复功能用例回收站批量恢复的问题

--bug=1015435 --user=宋昌昌 [测试跟踪]github#16367回收站选择所有数据,批量恢复用例,每次只恢复10条 https://www.tapd.cn/55049933/s/1213602
This commit is contained in:
song-cc-rock 2022-07-27 15:38:35 +08:00 committed by jianxing
parent dea49feebd
commit 1dcb1cfe5c
2 changed files with 27 additions and 16 deletions

View File

@ -128,13 +128,15 @@ public class IssuesService {
attachmentService.copyAttachment(attachmentRequest); attachmentService.copyAttachment(attachmentRequest);
} else { } else {
// 新增, 需保存并同步所有待上传的附件 // 新增, 需保存并同步所有待上传的附件
final String issueId = issues.getId(); if (CollectionUtils.isNotEmpty(files)) {
files.forEach(file -> { final String issueId = issues.getId();
AttachmentRequest attachmentRequest = new AttachmentRequest(); files.forEach(file -> {
attachmentRequest.setBelongId(issueId); AttachmentRequest attachmentRequest = new AttachmentRequest();
attachmentRequest.setBelongType(AttachmentType.ISSUE.type()); attachmentRequest.setBelongId(issueId);
attachmentService.uploadAttachment(attachmentRequest, file); attachmentRequest.setBelongType(AttachmentType.ISSUE.type());
}); attachmentService.uploadAttachment(attachmentRequest, file);
});
}
} }
return issues; return issues;
} }

View File

@ -1968,12 +1968,14 @@ public class TestCaseService {
attachmentService.copyAttachment(attachmentRequest); attachmentService.copyAttachment(attachmentRequest);
} else { } else {
// 新增需上传用例所有待上传的附件 // 新增需上传用例所有待上传的附件
files.forEach(file -> { if (CollectionUtils.isNotEmpty(files)) {
AttachmentRequest attachmentRequest = new AttachmentRequest(); files.forEach(file -> {
attachmentRequest.setBelongId(testCaseWithBLOBs.getId()); AttachmentRequest attachmentRequest = new AttachmentRequest();
attachmentRequest.setBelongType(AttachmentType.TEST_CASE.type()); attachmentRequest.setBelongId(testCaseWithBLOBs.getId());
attachmentService.uploadAttachment(attachmentRequest, file); attachmentRequest.setBelongType(AttachmentType.TEST_CASE.type());
}); attachmentService.uploadAttachment(attachmentRequest, file);
});
}
} }
return testCaseWithBLOBs; return testCaseWithBLOBs;
} }
@ -2267,13 +2269,20 @@ public class TestCaseService {
} }
public void reduction(TestCaseBatchRequest request) { public void reduction(TestCaseBatchRequest request) {
if (CollectionUtils.isNotEmpty(request.getIds())) { List<String> ids = new ArrayList<>();
extTestCaseMapper.checkOriginalStatusByIds(request.getIds()); if (request.getCondition().isSelectAll()) {
List<TestCaseDTO> 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(); TestCaseExample example = new TestCaseExample();
// 关联版本之后必须查询每一个数据的所有版本依次还原 // 关联版本之后必须查询每一个数据的所有版本依次还原
example.createCriteria().andIdIn(request.getIds()); example.createCriteria().andIdIn(ids);
List<TestCase> reductionCaseList = testCaseMapper.selectByExample(example); List<TestCase> reductionCaseList = testCaseMapper.selectByExample(example);
List<String> refIds = reductionCaseList.stream().map(TestCase::getRefId).collect(Collectors.toList()); List<String> refIds = reductionCaseList.stream().map(TestCase::getRefId).collect(Collectors.toList());
example.clear(); example.clear();