提交 f835d627 编写于 作者: C chenjianxing

fix 节点拖拽

上级 a7b0255e
......@@ -373,15 +373,34 @@ public class TestCaseNodeService {
editNode(request);
List<TestCaseDTO> testCases = QueryTestCaseByNodeIds(request.getNodeIds());
List<String> nodeIds = request.getNodeIds();
List<TestCaseDTO> testCases = QueryTestCaseByNodeIds(nodeIds);
TestCaseNodeDTO nodeTree = request.getNodeTree();
buildUpdateTestCase(nodeTree, testCases, "/");
List<TestCaseNode> updateNodes = new ArrayList<>();
buildUpdateTestCase(nodeTree, testCases, updateNodes, "/", 1);
updateNodes = updateNodes.stream()
.filter(item -> nodeIds.contains(item.getId()))
.collect(Collectors.toList());
batchUpdateTestCaseNode(updateNodes);
batchUpdateTestCase(testCases);
}
private void batchUpdateTestCaseNode(List<TestCaseNode> updateNodes) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseNodeMapper testCaseNodeMapper = sqlSession.getMapper(TestCaseNodeMapper.class);
updateNodes.forEach((value) -> {
testCaseNodeMapper.updateByPrimaryKeySelective(value);
});
sqlSession.flushStatements();
}
private void batchUpdateTestCase(List<TestCaseDTO> testCases) {
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH);
TestCaseMapper testCaseMapper = sqlSession.getMapper(TestCaseMapper.class);
......@@ -397,10 +416,16 @@ public class TestCaseNodeService {
return extTestCaseMapper.list(testCaseRequest);
}
private void buildUpdateTestCase(TestCaseNodeDTO rootNode, List<TestCaseDTO> testCases, String rootPath) {
private void buildUpdateTestCase(TestCaseNodeDTO rootNode, List<TestCaseDTO> testCases,
List<TestCaseNode> updateNodes, String rootPath, int level) {
rootPath = rootPath + rootNode.getName();
TestCaseNode testCaseNode = new TestCaseNode();
testCaseNode.setId(rootNode.getId());
testCaseNode.setLevel(level);
updateNodes.add(testCaseNode);
for (TestCaseDTO item : testCases) {
if (StringUtils.equals(item.getNodeId(), rootNode.getId())) {
item.setNodePath(rootPath);
......@@ -410,7 +435,7 @@ public class TestCaseNodeService {
List<TestCaseNodeDTO> children = rootNode.getChildren();
if (children != null && children.size() > 0){
for (int i = 0; i < children.size(); i++) {
buildUpdateTestCase(children.get(i), testCases, rootPath + '/');
buildUpdateTestCase(children.get(i), testCases, updateNodes, rootPath + '/', level + 1);
}
}
}
......
......@@ -38,7 +38,7 @@
if (this.data.length > 4) {
let lastData = this.data[this.data.length - 1];
this.data.splice(1, this.data.length);
this.data.push('...');
this.data.push({id:lastData.id + '1', name:'...'});
this.data.push(lastData);
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册