|
@@ -4,6 +4,7 @@ package seecoder.devcloud.web.service.impl.tree;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import seecoder.devcloud.common.exceptions.ServiceException;
|
|
import seecoder.devcloud.common.exceptions.ServiceException;
|
|
|
import seecoder.devcloud.common.util.DateUtil;
|
|
import seecoder.devcloud.common.util.DateUtil;
|
|
|
import seecoder.devcloud.core.commit.CommitState;
|
|
import seecoder.devcloud.core.commit.CommitState;
|
|
@@ -41,14 +42,33 @@ public class TreeNodeServiceImpl implements TreeNodeService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
public List<TreeNodeVO> listTreeNodesByProjectId(int projectId) {
|
|
public List<TreeNodeVO> listTreeNodesByProjectId(int projectId) {
|
|
|
|
|
+ SimpleDateFormat format = DateUtil.getSimpleDateFormat();
|
|
|
List<TreeNodePO> nodes = treeNodeMapper.listTreeNodesByProjectId(projectId);
|
|
List<TreeNodePO> nodes = treeNodeMapper.listTreeNodesByProjectId(projectId);
|
|
|
|
|
+ if (nodes.size() == 0){
|
|
|
|
|
+ TreeNodePO defaultRoot = TreeNodePO.builder()
|
|
|
|
|
+ .deep(1)
|
|
|
|
|
+ .leaf(false)
|
|
|
|
|
+ .startTime(format.format(new Date()))
|
|
|
|
|
+ .projectId(projectId)
|
|
|
|
|
+ .state(NodeStateEnum.CREATED)
|
|
|
|
|
+ .title("default root")
|
|
|
|
|
+ .description("根节点")
|
|
|
|
|
+ .type(NodeTypeEnum.REQUIREMENT)
|
|
|
|
|
+ .timeToTake(0L)
|
|
|
|
|
+ .build();
|
|
|
|
|
+ treeNodeMapper.insertTreeNode(defaultRoot);
|
|
|
|
|
+ nodes.add(defaultRoot);
|
|
|
|
|
+ }
|
|
|
return getTreeNodeVOS(nodes);
|
|
return getTreeNodeVOS(nodes);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
@TreeLogging(OperationEnum.START)
|
|
@TreeLogging(OperationEnum.START)
|
|
|
public void insertTreeNode(TreeNodeCreateVO treeNodeCreateVO) throws ServiceException {
|
|
public void insertTreeNode(TreeNodeCreateVO treeNodeCreateVO) throws ServiceException {
|
|
|
|
|
+
|
|
|
TreeNodePO treeNodePO = new TreeNodePO();
|
|
TreeNodePO treeNodePO = new TreeNodePO();
|
|
|
BeanUtils.copyProperties(treeNodeCreateVO,treeNodePO);
|
|
BeanUtils.copyProperties(treeNodeCreateVO,treeNodePO);
|
|
|
int res = treeNodeMapper.insertTreeNode(treeNodePO);
|
|
int res = treeNodeMapper.insertTreeNode(treeNodePO);
|
|
@@ -59,6 +79,7 @@ public class TreeNodeServiceImpl implements TreeNodeService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
@TreeLogging(OperationEnum.UPDATE)
|
|
@TreeLogging(OperationEnum.UPDATE)
|
|
|
public void updateTreeNode(TreeNodeUpdateBasicVO treeNodeUpdateBasicVO) {
|
|
public void updateTreeNode(TreeNodeUpdateBasicVO treeNodeUpdateBasicVO) {
|
|
|
TreeNodePO treeNodePO = new TreeNodePO();
|
|
TreeNodePO treeNodePO = new TreeNodePO();
|
|
@@ -68,6 +89,7 @@ public class TreeNodeServiceImpl implements TreeNodeService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
public void deleteTreeNode(int nodeId) {
|
|
public void deleteTreeNode(int nodeId) {
|
|
|
|
|
|
|
|
treeNodeMapper.deleteTreeNode(nodeId);
|
|
treeNodeMapper.deleteTreeNode(nodeId);
|
|
@@ -79,6 +101,7 @@ public class TreeNodeServiceImpl implements TreeNodeService {
|
|
|
* 根据父节点id插入一个新的子节点
|
|
* 根据父节点id插入一个新的子节点
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Transactional
|
|
|
@TreeLogging(OperationEnum.START)
|
|
@TreeLogging(OperationEnum.START)
|
|
|
public Integer insertTreeNodeByFatherNode(int fatherId) throws ServiceException {
|
|
public Integer insertTreeNodeByFatherNode(int fatherId) throws ServiceException {
|
|
|
TreeNodePO treeNodePO = getDefaultTreeNodePO();
|
|
TreeNodePO treeNodePO = getDefaultTreeNodePO();
|
|
@@ -112,7 +135,7 @@ public class TreeNodeServiceImpl implements TreeNodeService {
|
|
|
treeNodePO.setType(NodeTypeEnum.TASK);
|
|
treeNodePO.setType(NodeTypeEnum.TASK);
|
|
|
treeNodePO.setPriority(PriorityEnum.MIDDLE);
|
|
treeNodePO.setPriority(PriorityEnum.MIDDLE);
|
|
|
treeNodePO.setState(NodeStateEnum.CREATED);
|
|
treeNodePO.setState(NodeStateEnum.CREATED);
|
|
|
- treeNodePO.setTimeToTake(10);
|
|
|
|
|
|
|
+ treeNodePO.setTimeToTake(10L);
|
|
|
treeNodePO.setStartTime(format.format(new Date()));
|
|
treeNodePO.setStartTime(format.format(new Date()));
|
|
|
treeNodePO.setEndTime(format.format(new Date()));
|
|
treeNodePO.setEndTime(format.format(new Date()));
|
|
|
treeNodePO.setLeaf(true);
|
|
treeNodePO.setLeaf(true);
|