Browse Source

merge xzh

ChenYZ 5 năm trước cách đây
mục cha
commit
08de3e4ac0

+ 4 - 0
common/pom.xml

@@ -56,6 +56,10 @@
                 </exclusion>
             </exclusions>
         </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+        </dependency>
 
     </dependencies>
 

+ 7 - 0
web/pom.xml

@@ -79,6 +79,13 @@
                 </exclusion>
             </exclusions>
         </dependency>
+
+        <dependency>
+            <groupId>org.mybatis.spring.boot</groupId>
+            <artifactId>mybatis-spring-boot-starter</artifactId>
+            <version>2.1.4</version>
+        </dependency>
+
     </dependencies>
 
     <dependencyManagement>

+ 26 - 0
web/src/main/java/seecoder/devcloud/web/controller/TreeNodesController.java

@@ -0,0 +1,26 @@
+package seecoder.devcloud.web.controller;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+import seecoder.devcloud.web.po.TreeNode;
+import seecoder.devcloud.web.service.TreeNodeService;
+
+import java.util.List;
+
+@RestController
+public class TreeNodesController {
+    @Autowired
+    private TreeNodeService treeNodeService;
+    //注意 这里混用po和vo了
+    @GetMapping("/all")
+    public List<TreeNode> getAllNodes(){
+        return treeNodeService.getAllNodes();
+    }
+    @GetMapping("/")
+    public String test(){
+        return "123";
+    }
+
+}

+ 16 - 0
web/src/main/java/seecoder/devcloud/web/dataMapper/TreeNodeMapper.java

@@ -0,0 +1,16 @@
+package seecoder.devcloud.web.dataMapper;
+
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import seecoder.devcloud.web.po.TreeNode;
+
+import java.util.List;
+
+@Mapper
+public interface TreeNodeMapper {
+
+    List<TreeNode> findAllTreeNodes();
+    List<TreeNode> findTreeNodeById(@Param("id") int id);
+
+}

+ 5 - 0
web/src/main/java/seecoder/devcloud/web/enums/State.java

@@ -0,0 +1,5 @@
+package seecoder.devcloud.web.enums;
+
+public enum State {
+    PROCESSING,FINISHED
+}

+ 5 - 0
web/src/main/java/seecoder/devcloud/web/enums/Type.java

@@ -0,0 +1,5 @@
+package seecoder.devcloud.web.enums;
+
+public enum Type {
+    REQUIREMENT,TASK
+}

+ 155 - 0
web/src/main/java/seecoder/devcloud/web/po/TreeNode.java

@@ -0,0 +1,155 @@
+package seecoder.devcloud.web.po;
+
+
+
+import seecoder.devcloud.web.enums.State;
+import seecoder.devcloud.web.enums.Type;
+
+import java.util.Date;
+
+public class TreeNode {
+    private int id;
+    private String title;
+    private String description;
+    private Type type;
+    private int priority;
+    private State state;
+    private String processor;
+    private int time_to_take;
+    private Date start_time;
+    private Date end_time;
+    private boolean is_leaf;
+    private int group_id;
+
+    public TreeNode() {
+    }
+
+    public TreeNode(int id, String title, String description, Type type, int priority, State state, String processor, int time_to_take, Date start_time, Date end_time, boolean is_leaf, int group_id) {
+        this.id = id;
+        this.title = title;
+        this.description = description;
+        this.type = type;
+        this.priority = priority;
+        this.state = state;
+        this.processor = processor;
+        this.time_to_take = time_to_take;
+        this.start_time = start_time;
+        this.end_time = end_time;
+        this.is_leaf = is_leaf;
+        this.group_id = group_id;
+    }
+
+    public int getId() {
+        return id;
+    }
+
+    public void setId(int id) {
+        this.id = id;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String getDescription() {
+        return description;
+    }
+
+    public void setDescription(String description) {
+        this.description = description;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public void setType(Type type) {
+        this.type = type;
+    }
+
+    public int getPriority() {
+        return priority;
+    }
+
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    public State getState() {
+        return state;
+    }
+
+    public void setState(State state) {
+        this.state = state;
+    }
+
+    public String getProcessor() {
+        return processor;
+    }
+
+    public void setProcessor(String processor) {
+        this.processor = processor;
+    }
+
+    public int getTime_to_take() {
+        return time_to_take;
+    }
+
+    public void setTime_to_take(int time_to_take) {
+        this.time_to_take = time_to_take;
+    }
+
+    public Date getStart_time() {
+        return start_time;
+    }
+
+    public void setStart_time(Date start_time) {
+        this.start_time = start_time;
+    }
+
+    public Date getEnd_time() {
+        return end_time;
+    }
+
+    public void setEnd_time(Date end_time) {
+        this.end_time = end_time;
+    }
+
+    public boolean isIs_leaf() {
+        return is_leaf;
+    }
+
+    public void setIs_leaf(boolean is_leaf) {
+        this.is_leaf = is_leaf;
+    }
+
+    public int getGroup_id() {
+        return group_id;
+    }
+
+    public void setGroup_id(int group_id) {
+        this.group_id = group_id;
+    }
+
+    @Override
+    public String toString() {
+        return "TreeNode{" +
+                "id=" + id +
+                ", title='" + title + '\'' +
+                ", description='" + description + '\'' +
+                ", type=" + type +
+                ", priority=" + priority +
+                ", state=" + state +
+                ", processor='" + processor + '\'' +
+                ", time_to_take=" + time_to_take +
+                ", start_time=" + start_time +
+                ", end_time=" + end_time +
+                ", is_leaf=" + is_leaf +
+                ", group_id=" + group_id +
+                '}';
+    }
+}

+ 11 - 0
web/src/main/java/seecoder/devcloud/web/service/TreeNodeService.java

@@ -0,0 +1,11 @@
+package seecoder.devcloud.web.service;
+
+
+
+import seecoder.devcloud.web.po.TreeNode;
+
+import java.util.List;
+
+public interface TreeNodeService {
+    public List<TreeNode> getAllNodes();
+}

+ 20 - 0
web/src/main/java/seecoder/devcloud/web/service/impl/tree/TreeNodeServiceImpl.java

@@ -0,0 +1,20 @@
+package seecoder.devcloud.web.service.impl.tree;
+
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import seecoder.devcloud.web.dataMapper.TreeNodeMapper;
+import seecoder.devcloud.web.po.TreeNode;
+import seecoder.devcloud.web.service.TreeNodeService;
+
+import java.util.List;
+
+@Service
+public class TreeNodeServiceImpl implements TreeNodeService {
+    @Autowired
+    private TreeNodeMapper treeNodeMapper;
+    @Override
+    public List<TreeNode> getAllNodes() {
+        return treeNodeMapper.findAllTreeNodes();
+    }
+}

+ 57 - 0
web/src/main/resources/SQLScripts/trees.sql

@@ -0,0 +1,57 @@
+create database if not exists seecoder;
+use seecoder;
+create table tree_nodes
+(
+    id           int auto_increment,
+    title        varchar(24)                        not null,
+    description  varchar(512)                       null,
+    type         int      default 0                 not null,
+    priority     int      default 0                 null,
+    state        int      default 0                 not null,
+    processor    varchar(64)                        not null,
+    time_to_take int      default 0                 not null,
+    start_time   datetime default CURRENT_TIMESTAMP null,
+    end_time     datetime                           null,
+    is_leaf      int      default 0                 null,
+    group_id     int                                null,
+    constraint tree_nodes_id_uindex
+        unique (id)
+);
+
+alter table tree_nodes
+    add primary key (id);
+
+create table messages
+(
+    message_id   int auto_increment,
+    creator      varchar(64)  not null,
+    tree_node_id int          null,
+    detail       varchar(512) null,
+    constraint messages_message_id_uindex
+        unique (message_id),
+    constraint tree_node_fk
+        foreign key (tree_node_id) references tree_nodes (id)
+            on update cascade on delete cascade
+);
+
+alter table messages
+    add primary key (message_id);
+
+create table tree_sides
+(
+    side_id   int auto_increment,
+    parent_id int null,
+    child_id  int null,
+    constraint tree_sides_side_id_uindex
+        unique (side_id),
+    constraint child_fk
+        foreign key (child_id) references tree_nodes (id)
+            on update cascade on delete cascade,
+    constraint parent_fk
+        foreign key (parent_id) references tree_nodes (id)
+            on update cascade on delete cascade
+);
+
+alter table tree_sides
+    add primary key (side_id);
+

+ 1 - 1
web/src/main/resources/application-dev.yml

@@ -5,7 +5,7 @@ spring:
     url: jdbc:mysql://localhost:3306/seecoder?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false
 #    url: jdbc:mysql://218.94.159.108:13306/seec_ii?useUnicode=true&characterEncoding=UTF-8&useSSL=false
     username: root
-    password: 123456
+    password: xizhiheng921
   jpa:
     hibernate:
       ddl-auto: update

+ 1 - 1
web/src/main/resources/application-wph.yml

@@ -3,7 +3,7 @@ spring:
   datasource:
     url: jdbc:mysql://localhost:3306/seecoder?useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT%2B8&useSSL=false
     username: root
-    password: 123456
+    password: xizhiheng921
   jpa:
     hibernate:
       ddl-auto: update

+ 21 - 0
web/src/main/resources/seecoder/devcloud/web/dataMapper/TreeNodeMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="seecoder.devcloud.web.dataMapper.TreeNodeMapper">
+
+    <resultMap id="treeNodeMap" type="seecoder.devcloud.web.po.TreeNode" >
+        <id column="id" property="id"/>
+        <result column="type" property="type" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+        <result column="state" property="state" typeHandler="org.apache.ibatis.type.EnumOrdinalTypeHandler"/>
+
+    </resultMap>
+
+    <select id="findAllTreeNodes"  resultMap="treeNodeMap">
+        SELECT * FROM tree_nodes
+    </select>
+    <select id="findTreeNodeById"  resultMap="treeNodeMap">
+        SELECT * FROM tree_nodes where id = #{id}
+    </select>
+</mapper>