fix(功能用例): 修复用例脑图删除文本节点问题

This commit is contained in:
guoyuqi 2024-06-20 16:23:06 +08:00 committed by Craftsman
parent a4243dfda3
commit 04d4115546
2 changed files with 30 additions and 6 deletions

View File

@ -779,6 +779,9 @@ public class FunctionalCaseMinderService {
private MindAdditionalNode updateNode(String userId, MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNodeMapper mindAdditionalNodeMapper) { private MindAdditionalNode updateNode(String userId, MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNodeMapper mindAdditionalNodeMapper) {
MindAdditionalNode mindAdditionalNode = new MindAdditionalNode(); MindAdditionalNode mindAdditionalNode = new MindAdditionalNode();
mindAdditionalNode.setId(mindAdditionalNodeRequest.getId()); mindAdditionalNode.setId(mindAdditionalNodeRequest.getId());
if (mindAdditionalNodeRequest.getName().length()>255) {
mindAdditionalNodeRequest.setName(mindAdditionalNodeRequest.getName().substring(0,249));
}
mindAdditionalNode.setName(mindAdditionalNodeRequest.getName()); mindAdditionalNode.setName(mindAdditionalNodeRequest.getName());
mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId()); mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId());
mindAdditionalNode.setUpdateTime(System.currentTimeMillis()); mindAdditionalNode.setUpdateTime(System.currentTimeMillis());
@ -791,6 +794,9 @@ public class FunctionalCaseMinderService {
private MindAdditionalNode buildNode(FunctionalCaseMinderEditRequest request, String userId, MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNodeMapper additionalNodeMapper) { private MindAdditionalNode buildNode(FunctionalCaseMinderEditRequest request, String userId, MindAdditionalNodeRequest mindAdditionalNodeRequest, MindAdditionalNodeMapper additionalNodeMapper) {
MindAdditionalNode mindAdditionalNode = new MindAdditionalNode(); MindAdditionalNode mindAdditionalNode = new MindAdditionalNode();
mindAdditionalNode.setId(IDGenerator.nextStr()); mindAdditionalNode.setId(IDGenerator.nextStr());
if (mindAdditionalNodeRequest.getName().length()>255) {
mindAdditionalNodeRequest.setName(mindAdditionalNodeRequest.getName().substring(0,249));
}
mindAdditionalNode.setName(mindAdditionalNodeRequest.getName()); mindAdditionalNode.setName(mindAdditionalNodeRequest.getName());
mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId()); mindAdditionalNode.setParentId(mindAdditionalNodeRequest.getParentId());
mindAdditionalNode.setProjectId(request.getProjectId()); mindAdditionalNode.setProjectId(request.getProjectId());
@ -813,7 +819,7 @@ public class FunctionalCaseMinderService {
if (CollectionUtils.isNotEmpty(addList)) { if (CollectionUtils.isNotEmpty(addList)) {
List<FunctionalCaseModule> modules = new ArrayList<>(); List<FunctionalCaseModule> modules = new ArrayList<>();
//查出已存在同层级的节点 //查出已存在同层级的节点
Map<String, List<FunctionalCaseModule>> parentIdInDBMap = getParentIdInDBMap(addList); Map<String, List<FunctionalCaseModule>> parentIdInDBMap = getParentIdInDBMap(addList,request.getProjectId());
for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : addList) { for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : addList) {
FunctionalCaseModule functionalCaseModule = buildModule(request, userId, functionalCaseModuleEditRequest); FunctionalCaseModule functionalCaseModule = buildModule(request, userId, functionalCaseModuleEditRequest);
modules.add(functionalCaseModule); modules.add(functionalCaseModule);
@ -832,7 +838,7 @@ public class FunctionalCaseMinderService {
List<FunctionalCaseModuleEditRequest> updateList = resourceMap.get(OperationLogType.UPDATE.toString()); List<FunctionalCaseModuleEditRequest> updateList = resourceMap.get(OperationLogType.UPDATE.toString());
if (CollectionUtils.isNotEmpty(updateList)) { if (CollectionUtils.isNotEmpty(updateList)) {
List<FunctionalCaseModule> modules = new ArrayList<>(); List<FunctionalCaseModule> modules = new ArrayList<>();
Map<String, List<FunctionalCaseModule>> parentIdInDBMap = getParentIdInDBMap(updateList); Map<String, List<FunctionalCaseModule>> parentIdInDBMap = getParentIdInDBMap(updateList, request.getProjectId());
for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : updateList) { for (FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest : updateList) {
FunctionalCaseModule updateModule = updateModule(userId, functionalCaseModuleEditRequest); FunctionalCaseModule updateModule = updateModule(userId, functionalCaseModuleEditRequest);
modules.add(updateModule); modules.add(updateModule);
@ -856,10 +862,10 @@ public class FunctionalCaseMinderService {
} }
@NotNull @NotNull
private Map<String, List<FunctionalCaseModule>> getParentIdInDBMap(List<FunctionalCaseModuleEditRequest> functionalCaseModuleEditRequests) { private Map<String, List<FunctionalCaseModule>> getParentIdInDBMap(List<FunctionalCaseModuleEditRequest> functionalCaseModuleEditRequests, String projectId) {
List<String> parentIds = functionalCaseModuleEditRequests.stream().map(FunctionalCaseModuleEditRequest::getParentId).toList(); List<String> parentIds = functionalCaseModuleEditRequests.stream().map(FunctionalCaseModuleEditRequest::getParentId).toList();
FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample(); FunctionalCaseModuleExample functionalCaseModuleExample = new FunctionalCaseModuleExample();
functionalCaseModuleExample.createCriteria().andParentIdIn(parentIds); functionalCaseModuleExample.createCriteria().andParentIdIn(parentIds).andProjectIdEqualTo(projectId);
List<FunctionalCaseModule> sameParentListInDB = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample); List<FunctionalCaseModule> sameParentListInDB = functionalCaseModuleMapper.selectByExample(functionalCaseModuleExample);
return sameParentListInDB.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getParentId)); return sameParentListInDB.stream().collect(Collectors.groupingBy(FunctionalCaseModule::getParentId));
} }
@ -963,6 +969,9 @@ public class FunctionalCaseMinderService {
private FunctionalCaseModule buildModule(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest) { private FunctionalCaseModule buildModule(FunctionalCaseMinderEditRequest request, String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest) {
FunctionalCaseModule functionalCaseModule = new FunctionalCaseModule(); FunctionalCaseModule functionalCaseModule = new FunctionalCaseModule();
functionalCaseModule.setId(IDGenerator.nextStr()); functionalCaseModule.setId(IDGenerator.nextStr());
if (functionalCaseModuleEditRequest.getName().length()>255) {
functionalCaseModuleEditRequest.setName(functionalCaseModuleEditRequest.getName().substring(0,249));
}
functionalCaseModule.setName(functionalCaseModuleEditRequest.getName()); functionalCaseModule.setName(functionalCaseModuleEditRequest.getName());
functionalCaseModule.setParentId(functionalCaseModuleEditRequest.getParentId()); functionalCaseModule.setParentId(functionalCaseModuleEditRequest.getParentId());
functionalCaseModule.setProjectId(request.getProjectId()); functionalCaseModule.setProjectId(request.getProjectId());
@ -978,6 +987,9 @@ public class FunctionalCaseMinderService {
private FunctionalCaseModule updateModule(String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest) { private FunctionalCaseModule updateModule(String userId, FunctionalCaseModuleEditRequest functionalCaseModuleEditRequest) {
FunctionalCaseModule updateModule = new FunctionalCaseModule(); FunctionalCaseModule updateModule = new FunctionalCaseModule();
updateModule.setId(functionalCaseModuleEditRequest.getId()); updateModule.setId(functionalCaseModuleEditRequest.getId());
if (functionalCaseModuleEditRequest.getName().length()>255) {
functionalCaseModuleEditRequest.setName(functionalCaseModuleEditRequest.getName().substring(0,249));
}
updateModule.setName(functionalCaseModuleEditRequest.getName()); updateModule.setName(functionalCaseModuleEditRequest.getName());
updateModule.setParentId(functionalCaseModuleEditRequest.getParentId()); updateModule.setParentId(functionalCaseModuleEditRequest.getParentId());
updateModule.setUpdateTime(System.currentTimeMillis()); updateModule.setUpdateTime(System.currentTimeMillis());
@ -990,6 +1002,9 @@ public class FunctionalCaseMinderService {
private FunctionalCase updateCase(FunctionalCaseChangeRequest request, String userId, FunctionalCaseMapper caseMapper) { private FunctionalCase updateCase(FunctionalCaseChangeRequest request, String userId, FunctionalCaseMapper caseMapper) {
FunctionalCase functionalCase = new FunctionalCase(); FunctionalCase functionalCase = new FunctionalCase();
BeanUtils.copyBean(functionalCase, request); BeanUtils.copyBean(functionalCase, request);
if (functionalCase.getName().length()>255) {
functionalCase.setName(functionalCase.getName().substring(0,249));
}
functionalCase.setUpdateUser(userId); functionalCase.setUpdateUser(userId);
functionalCase.setUpdateTime(System.currentTimeMillis()); functionalCase.setUpdateTime(System.currentTimeMillis());
functionalCase.setCreateUser(null); functionalCase.setCreateUser(null);
@ -1112,6 +1127,9 @@ public class FunctionalCaseMinderService {
if (StringUtils.isNotBlank(sourceIdAndInsertModuleIdMap.get(functionalCaseChangeRequest.getModuleId()))) { if (StringUtils.isNotBlank(sourceIdAndInsertModuleIdMap.get(functionalCaseChangeRequest.getModuleId()))) {
functionalCase.setModuleId(sourceIdAndInsertModuleIdMap.get(functionalCaseChangeRequest.getModuleId())); functionalCase.setModuleId(sourceIdAndInsertModuleIdMap.get(functionalCaseChangeRequest.getModuleId()));
} }
if (functionalCase.getName().length()>255) {
functionalCase.setName(functionalCase.getName().substring(0,249));
}
functionalCase.setProjectId(request.getProjectId()); functionalCase.setProjectId(request.getProjectId());
functionalCase.setVersionId(request.getVersionId()); functionalCase.setVersionId(request.getVersionId());
functionalCase.setNum(functionalCaseService.getNextNum(request.getProjectId())); functionalCase.setNum(functionalCaseService.getNextNum(request.getProjectId()));
@ -1153,7 +1171,7 @@ public class FunctionalCaseMinderService {
} }
List<MinderOptionDTO> additionalOptionDTOS = resourceMap.get(ModuleConstants.ROOT_NODE_PARENT_ID); List<MinderOptionDTO> additionalOptionDTOS = resourceMap.get(ModuleConstants.ROOT_NODE_PARENT_ID);
if (CollectionUtils.isNotEmpty(additionalOptionDTOS)) { if (CollectionUtils.isNotEmpty(additionalOptionDTOS)) {
List<String> mindAdditionalNodeIds = caseModuleOptionDTOS.stream().map(MinderOptionDTO::getId).toList(); List<String> mindAdditionalNodeIds = additionalOptionDTOS.stream().map(MinderOptionDTO::getId).toList();
dealMindAdditionalMode(mindAdditionalNodeIds, mindAdditionalNodeMapper); dealMindAdditionalMode(mindAdditionalNodeIds, mindAdditionalNodeMapper);
} }
} }

View File

@ -371,6 +371,9 @@ public class TestPlanCollectionMinderService {
} else { } else {
testPlanCollection.setParentId(parent.getId()); testPlanCollection.setParentId(parent.getId());
} }
if (testPlanCollectionMinderEditDTO.getText().length()>255) {
testPlanCollectionMinderEditDTO.setText(testPlanCollectionMinderEditDTO.getText().substring(0,249));
}
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText()); testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
testPlanCollection.setTestPlanId(request.getPlanId()); testPlanCollection.setTestPlanId(request.getPlanId());
testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType()); testPlanCollection.setType(testPlanCollectionMinderEditDTO.getType());
@ -393,6 +396,9 @@ public class TestPlanCollectionMinderService {
BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO); BeanUtils.copyBean(testPlanCollection, testPlanCollectionMinderEditDTO);
} }
testPlanCollection.setParentId(parent.getId()); testPlanCollection.setParentId(parent.getId());
if (testPlanCollectionMinderEditDTO.getText().length()>255) {
testPlanCollectionMinderEditDTO.setText(testPlanCollectionMinderEditDTO.getText().substring(0,249));
}
testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText()); testPlanCollection.setName(testPlanCollectionMinderEditDTO.getText());
testPlanCollection.setId(IDGenerator.nextStr()); testPlanCollection.setId(IDGenerator.nextStr());
testPlanCollection.setTestPlanId(request.getPlanId()); testPlanCollection.setTestPlanId(request.getPlanId());