mirror of
https://gitee.com/fit2cloud-feizhiyun/MeterSphere.git
synced 2024-12-03 04:28:51 +08:00
refactor(测试计划): 脑图规划删除调整
This commit is contained in:
parent
796294ca3e
commit
3cc12dd46a
@ -24,7 +24,4 @@ public class TestPlanCollectionMinderEditRequest implements Serializable {
|
||||
@Schema(description = "新增/修改的节点集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<TestPlanCollectionMinderEditDTO> editList;
|
||||
|
||||
@Schema(description = "删除的节点集合", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||
private List<String> deletedIds;
|
||||
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import io.metersphere.plan.dto.request.TestPlanCollectionMinderEditRequest;
|
||||
import io.metersphere.plan.mapper.*;
|
||||
import io.metersphere.sdk.constants.ApiBatchRunMode;
|
||||
import io.metersphere.sdk.constants.CaseType;
|
||||
import io.metersphere.sdk.constants.CommonConstants;
|
||||
import io.metersphere.sdk.constants.ModuleConstants;
|
||||
import io.metersphere.sdk.util.BeanUtils;
|
||||
import io.metersphere.sdk.util.Translator;
|
||||
@ -100,9 +101,9 @@ public class TestPlanCollectionMinderService {
|
||||
BeanUtils.copyBean(typeTreeNodeDTO, testPlanCollection);
|
||||
typeTreeNodeDTO.setText(Translator.get(testPlanCollection.getName(), testPlanCollection.getName()));
|
||||
if (StringUtils.equalsIgnoreCase(testPlanCollection.getExecuteMethod(), ApiBatchRunMode.PARALLEL.toString())) {
|
||||
typeTreeNodeDTO.setPriority(2);
|
||||
} else {
|
||||
typeTreeNodeDTO.setPriority(3);
|
||||
} else {
|
||||
typeTreeNodeDTO.setPriority(2);
|
||||
}
|
||||
if (StringUtils.equalsIgnoreCase(CaseType.FUNCTIONAL_CASE.getKey(),testPlanCollection.getType())) {
|
||||
typeTreeNodeDTO.setPriority(null);
|
||||
@ -240,10 +241,6 @@ public class TestPlanCollectionMinderService {
|
||||
|
||||
|
||||
public void editMindTestPlanCase(TestPlanCollectionMinderEditRequest request, String userId) {
|
||||
//处理删除
|
||||
if (CollectionUtils.isNotEmpty(request.getDeletedIds())) {
|
||||
testPlanService.deletePlanCollectionResource(request.getDeletedIds());
|
||||
}
|
||||
Map<String, List<BaseCollectionAssociateRequest>> associateMap = new HashMap<>();
|
||||
//处理新增与更新
|
||||
dealEditList(request, userId, associateMap);
|
||||
@ -268,9 +265,14 @@ public class TestPlanCollectionMinderService {
|
||||
}
|
||||
}
|
||||
|
||||
private static void dealUpdateList(TestPlanCollectionMinderEditRequest request, String userId, Map<String, List<BaseCollectionAssociateRequest>> associateMap, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
private void dealUpdateList(TestPlanCollectionMinderEditRequest request, String userId, Map<String, List<BaseCollectionAssociateRequest>> associateMap, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
List<TestPlanCollectionMinderEditDTO> updateList = request.getEditList().stream().filter(t -> StringUtils.isNotBlank(t.getId())).toList();
|
||||
|
||||
|
||||
if (CollectionUtils.isNotEmpty(updateList)) {
|
||||
//处理删除
|
||||
deleteCollection(updateList);
|
||||
//处理更新
|
||||
for (TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO : updateList) {
|
||||
TestPlanCollection testPlanCollection = updateCollection(request, userId, testPlanCollectionMinderEditDTO, parentMap, collectionMapper);
|
||||
setAssociateMap(testPlanCollectionMinderEditDTO, associateMap, testPlanCollection);
|
||||
@ -278,6 +280,17 @@ public class TestPlanCollectionMinderService {
|
||||
}
|
||||
}
|
||||
|
||||
private void deleteCollection(List<TestPlanCollectionMinderEditDTO> updateList) {
|
||||
List<String> existIds = updateList.stream().map(TestPlanCollectionMinderEditDTO::getId).toList();
|
||||
TestPlanCollectionExample example = new TestPlanCollectionExample();
|
||||
example.createCriteria().andIdNotIn(existIds);
|
||||
List<TestPlanCollection> collections = testPlanCollectionMapper.selectByExample(example);
|
||||
if (CollectionUtils.isNotEmpty(collections)) {
|
||||
List<String> deletedIds = collections.stream().map(TestPlanCollection::getId).toList();
|
||||
testPlanService.deletePlanCollectionResource(deletedIds);
|
||||
}
|
||||
}
|
||||
|
||||
private static void dealAddList(TestPlanCollectionMinderEditRequest request, String userId, Map<String, List<BaseCollectionAssociateRequest>> associateMap, Map<String, List<TestPlanCollection>> parentMap, TestPlanCollectionMapper collectionMapper) {
|
||||
List<TestPlanCollectionMinderEditDTO> addList = request.getEditList().stream().filter(t -> StringUtils.isBlank(t.getId())).toList();
|
||||
if (CollectionUtils.isNotEmpty(addList)) {
|
||||
@ -325,8 +338,13 @@ public class TestPlanCollectionMinderService {
|
||||
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
|
||||
testPlanCollection.setTestPlanId(request.getPlanId());
|
||||
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
|
||||
TestPlanCollection parent = parentMap.get(testPlanCollectionMinderEditDTO.getType()).get(0);
|
||||
List<TestPlanCollection> testPlanCollections = parentMap.get(testPlanCollectionMinderEditDTO.getType());
|
||||
if (CollectionUtils.isNotEmpty(testPlanCollections)) {
|
||||
TestPlanCollection parent = testPlanCollections.get(0);
|
||||
testPlanCollection.setParentId(parent.getId());
|
||||
} else {
|
||||
testPlanCollection.setParentId(CommonConstants.DEFAULT_NULL_VALUE);
|
||||
}
|
||||
testPlanCollection.setCreateUser(userId);
|
||||
testPlanCollection.setCreateTime(System.currentTimeMillis());
|
||||
testPlanCollection.setPos(testPlanCollectionMinderEditDTO.getNum());
|
||||
|
@ -58,6 +58,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
TestPlanCollectionMinderEditRequest request = new TestPlanCollectionMinderEditRequest();
|
||||
request.setPlanId("gyq_plan_1");
|
||||
List<TestPlanCollectionMinderEditDTO> editList = new ArrayList<>();
|
||||
TestPlanCollectionMinderEditDTO deleteDTO = new TestPlanCollectionMinderEditDTO();
|
||||
TestPlanCollectionMinderEditDTO testPlanCollectionMinderEditDTO = new TestPlanCollectionMinderEditDTO();
|
||||
testPlanCollectionMinderEditDTO.setId("gyq_wxxx_4");
|
||||
testPlanCollectionMinderEditDTO.setText("更新名称");
|
||||
@ -79,6 +80,7 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
testPlanCollectionAssociateDTO.setIds(List.of("gyq_plan_api-case-associate-1"));
|
||||
associateDTOS.add(testPlanCollectionAssociateDTO);
|
||||
testPlanCollectionMinderEditDTO.setAssociateDTOS(associateDTOS);
|
||||
deleteDTO = testPlanCollectionMinderEditDTO;
|
||||
editList.add(testPlanCollectionMinderEditDTO);
|
||||
request.setEditList(editList);
|
||||
this.requestPostWithOkAndReturn(EDIT_MIND, request);
|
||||
@ -114,8 +116,9 @@ public class TestPlanCollectionMinderControllerTests extends BaseTest {
|
||||
testPlanCollectionExample.createCriteria().andNameEqualTo("新建名称");
|
||||
List<TestPlanCollection> testPlanCollections = testPlanCollectionMapper.selectByExample(testPlanCollectionExample);
|
||||
Assertions.assertTrue(CollectionUtils.isNotEmpty(testPlanCollections));
|
||||
request.setEditList(new ArrayList<>());
|
||||
request.setDeletedIds(List.of(testPlanCollections.get(0).getId()));
|
||||
editList = new ArrayList<>();
|
||||
editList.add(deleteDTO);
|
||||
request.setEditList(editList);
|
||||
this.requestPostWithOkAndReturn(EDIT_MIND, request);
|
||||
testPlanCollectionExample = new TestPlanCollectionExample();
|
||||
testPlanCollectionExample.createCriteria().andNameEqualTo("新建名称");
|
||||
|
Loading…
Reference in New Issue
Block a user