fix: 脑图无法删除用例

This commit is contained in:
chenjianxing 2021-07-30 10:40:13 +08:00 committed by jianxing
parent fe484a425d
commit 8ffa57619b
1 changed files with 29 additions and 31 deletions

View File

@ -1319,40 +1319,38 @@ public class TestCaseService {
public void minderEdit(TestCaseMinderEditRequest request) { public void minderEdit(TestCaseMinderEditRequest request) {
List<TestCaseWithBLOBs> data = request.getData(); List<TestCaseWithBLOBs> data = request.getData();
if (CollectionUtils.isEmpty(data)) { if (CollectionUtils.isNotEmpty(data)) {
return; List<String> editIds = data.stream()
} .filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20)
.map(TestCaseWithBLOBs::getId).collect(Collectors.toList());
List<String> editIds = data.stream() Map<String, TestCaseWithBLOBs> testCaseMap = new HashMap<>();
.filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20) if (CollectionUtils.isNotEmpty(editIds)) {
.map(TestCaseWithBLOBs::getId).collect(Collectors.toList()); TestCaseExample example = new TestCaseExample();
example.createCriteria().andIdIn(editIds);
Map<String, TestCaseWithBLOBs> testCaseMap = new HashMap<>(); List<TestCaseWithBLOBs> testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example);
if (CollectionUtils.isNotEmpty(editIds)) { testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t));
TestCaseExample example = new TestCaseExample();
example.createCriteria().andIdIn(editIds);
List<TestCaseWithBLOBs> testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example);
testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t));
}
Map<String, TestCaseWithBLOBs> finalTestCaseMap = testCaseMap;
data.forEach(item -> {
if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) {
item.setNodeId("");
} }
item.setProjectId(request.getProjectId());
if (StringUtils.isBlank(item.getId()) || item.getId().length() < 20) { Map<String, TestCaseWithBLOBs> finalTestCaseMap = testCaseMap;
item.setId(UUID.randomUUID().toString()); data.forEach(item -> {
item.setMaintainer(SessionUtils.getUserId()); if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) {
addTestCase(item); item.setNodeId("");
} else {
TestCaseWithBLOBs dbCase = finalTestCaseMap.get(item.getId());
if (editCustomFieldsPriority(dbCase, item.getPriority())) {
item.setCustomFields(dbCase.getCustomFields());
} }
editTestCase(item); item.setProjectId(request.getProjectId());
} if (StringUtils.isBlank(item.getId()) || item.getId().length() < 20) {
}); item.setId(UUID.randomUUID().toString());
item.setMaintainer(SessionUtils.getUserId());
addTestCase(item);
} else {
TestCaseWithBLOBs dbCase = finalTestCaseMap.get(item.getId());
if (editCustomFieldsPriority(dbCase, item.getPriority())) {
item.setCustomFields(dbCase.getCustomFields());
}
editTestCase(item);
}
});
}
List<String> ids = request.getIds(); List<String> ids = request.getIds();
if (CollectionUtils.isNotEmpty(ids)) { if (CollectionUtils.isNotEmpty(ids)) {
TestCaseBatchRequest deleteRequest = new TestCaseBatchRequest(); TestCaseBatchRequest deleteRequest = new TestCaseBatchRequest();