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 5d7689480c..82a2ebee14 100644 --- a/backend/src/main/java/io/metersphere/track/service/TestCaseService.java +++ b/backend/src/main/java/io/metersphere/track/service/TestCaseService.java @@ -1319,40 +1319,38 @@ public class TestCaseService { public void minderEdit(TestCaseMinderEditRequest request) { List data = request.getData(); - if (CollectionUtils.isEmpty(data)) { - return; - } + if (CollectionUtils.isNotEmpty(data)) { + List editIds = data.stream() + .filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20) + .map(TestCaseWithBLOBs::getId).collect(Collectors.toList()); - List editIds = data.stream() - .filter(t -> StringUtils.isNotBlank(t.getId()) && t.getId().length() > 20) - .map(TestCaseWithBLOBs::getId).collect(Collectors.toList()); - - Map testCaseMap = new HashMap<>(); - if (CollectionUtils.isNotEmpty(editIds)) { - TestCaseExample example = new TestCaseExample(); - example.createCriteria().andIdIn(editIds); - List testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example); - testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t)); - } - - Map finalTestCaseMap = testCaseMap; - data.forEach(item -> { - if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) { - item.setNodeId(""); + Map testCaseMap = new HashMap<>(); + if (CollectionUtils.isNotEmpty(editIds)) { + TestCaseExample example = new TestCaseExample(); + example.createCriteria().andIdIn(editIds); + List testCaseWithBLOBs = testCaseMapper.selectByExampleWithBLOBs(example); + testCaseMap = testCaseWithBLOBs.stream().collect(Collectors.toMap(TestCaseWithBLOBs::getId, t -> t)); } - 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()); + + Map finalTestCaseMap = testCaseMap; + data.forEach(item -> { + if (StringUtils.isBlank(item.getNodeId()) || item.getNodeId().equals("root")) { + item.setNodeId(""); } - 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 ids = request.getIds(); if (CollectionUtils.isNotEmpty(ids)) { TestCaseBatchRequest deleteRequest = new TestCaseBatchRequest();