فهرست منبع

fix: 子节点创建问题

370774330@qq.com 5 سال پیش
والد
کامیت
1a8dd443f9

+ 2 - 1
web/src/main/java/seecoder/devcloud/web/controller/tree/TreeNodesController.java

@@ -57,7 +57,8 @@ public class TreeNodesController {
     @PostMapping("/subNode/{fatherId}")
     @ApiImplicitParam(value = "fatherId",dataType ="int", paramType = "path")
     public Response insertTreeNodeByFatherNode(@PathVariable("fatherId") int fatherId) throws ServiceException {
-        return Response.buildSuccess(treeNodeService.insertTreeNodeByFatherNode(fatherId));
+        treeNodeService.insertTreeNodeByFatherNode(fatherId);
+        return Response.buildSuccess();
     }
 
     @ApiOperation(value = "修改节点属性", httpMethod = "PUT")

+ 18 - 9
web/src/main/java/seecoder/devcloud/web/service/impl/tree/TreeNodeServiceImpl.java

@@ -55,6 +55,7 @@ public class TreeNodeServiceImpl implements TreeNodeService {
                     .state(NodeStateEnum.CREATED)
                     .title("default root")
                     .description("根节点")
+                    .priority(PriorityEnum.MIDDLE)
                     .type(NodeTypeEnum.REQUIREMENT)
                     .timeToTake(0L)
             .build();
@@ -103,15 +104,23 @@ public class TreeNodeServiceImpl implements TreeNodeService {
     @Override
     @Transactional
     @TreeLogging(OperationEnum.START)
-    public Integer insertTreeNodeByFatherNode(int fatherId) throws ServiceException {
-        TreeNodePO treeNodePO = getDefaultTreeNodePO();
-        treeNodePO.setParentId(fatherId);
-        int res = treeNodeMapper.insertTreeNode(treeNodePO);
-        // TODO:safety check
-        if (res <= 0) {
-            throw new ServiceException(503,"插入需求节点失败");
-        }
-        return treeNodePO.getId();
+    public void insertTreeNodeByFatherNode(int fatherId) throws ServiceException {
+        SimpleDateFormat format = DateUtil.getSimpleDateFormat();
+        TreeNodePO father = treeNodeMapper.getTreeNodeById(fatherId);
+        TreeNodePO son = TreeNodePO.builder()
+                .parentId(fatherId)
+                .type(father.getDeep()+1==4?NodeTypeEnum.TASK:NodeTypeEnum.REQUIREMENT)
+                .title("默认子节点")
+                .description("子节点")
+                .state(NodeStateEnum.CREATED)
+                .projectId(father.getProjectId())
+                .startTime(format.format(new Date()))
+                .deep(father.getDeep()+1)
+                .leaf(father.getDeep()+1==4)
+                .priority(PriorityEnum.MIDDLE)
+                .timeToTake(0L)
+                .build();
+        treeNodeMapper.insertTreeNode(son);
     }
 
     @Override

+ 1 - 1
web/src/main/java/seecoder/devcloud/web/service/tree/TreeNodeService.java

@@ -43,7 +43,7 @@ public interface TreeNodeService {
      * @param fatherId
      * @return
      */
-    Integer insertTreeNodeByFatherNode(int fatherId) throws ServiceException;
+    void insertTreeNodeByFatherNode(int fatherId) throws ServiceException;
 
 
     List<TreeNodeVO> getNodesWithTaskTypeByProjectId(int projectId);