Prechádzať zdrojové kódy

Merge branch 'master' of http://39.108.133.138:3000/2001010134/RaoYing

wei 3 rokov pred
rodič
commit
097bc898e9

+ 5 - 0
src/main/java/WebsiteES/WebApp.java

@@ -0,0 +1,5 @@
+package WebsiteES;
+
+public class WebApp {
+    
+}

+ 777 - 0
src/main/java/group04/BasicNode.java

@@ -0,0 +1,777 @@
+package group04;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import group04.myBatis.Nodeinfo;
+
+/**
+ * basic node class of node, it can explane a single node and the level of node
+ */
+public class BasicNode implements Iterable<BasicNode>
+{
+
+    public boolean needUpload = true;
+    /**
+     * <0 : invalidity node
+     * =0 : undifineded node
+     * >0 : created node
+     */
+    private long id = 0l;
+
+    private BasicNode nextNode = null;
+    private BasicNode pervNode = null;
+
+    
+    private BasicNode childLevel = null;
+    private BasicNode parentNode = null;
+    
+
+    private static ArrayList<ArrayList<BasicNode>> loadedNodes = new ArrayList<>();
+
+    /**
+     * create new node
+     * @throws IOException no mapper
+     */
+    public BasicNode(){}
+
+    /**
+     * create node by confirm id
+     * @param id node id
+     * @throws IOException no mapper
+     */
+    public BasicNode(long id) throws IOException
+    {
+        setId(Math.abs(id));
+    }
+
+    
+    @Override
+    public NodeIterator iterator() {
+        BasicNode node = startOfNodeLevel();
+        return new NodeIterator(node);
+    }
+
+    /**
+     * get node id
+     * @return id of this node
+     */
+    public long getId() {
+        return id;
+    }
+
+    /**
+     * get next node of this node
+     * @return next node
+     */
+    public BasicNode getNextNode()
+    {
+        return nextNode;
+    }
+
+    /**
+     * get previous node of this node
+     * @return previous node
+     */
+    public BasicNode getPervNode()
+    {
+        return pervNode;
+    }
+
+    /**
+     * get parrent node of this node
+     * @return parrent node
+     */
+    public BasicNode getParentNode()
+    {
+        return parentNode;
+    }
+
+    /**
+     * get child level
+     * @return first node of child nodes
+     */
+    public BasicNode getChildLevel()
+    {
+        if(childLevel != null)
+        {
+            while(childLevel.pervNode != null)
+            {
+                childLevel = childLevel.pervNode;
+            }
+        }
+        return childLevel;
+    }
+
+    /**
+     * set Node id,also it can destroy this node by seting id to minus value
+     * @param id new id
+     * @throws IOException no mapper
+     */
+    public void setId(long id) throws IOException
+    {
+        synchronized(this)
+        {
+            //defineded id
+            if(id == 0 || !vaildity()) return;
+            //not null
+            if(id < 0)
+            {
+                //delete
+                NodeDao.getCurrentMapper().deleteByPrimaryKey(this.id);
+                //if database vaildity, it will going on.
+                dropFromLevel();
+                removeLoadedNode(this);
+                //delete all child nodes
+                BasicNode node = this.getChildLevel();
+                while(node != null)
+                {
+                    BasicNode next = node.getNextNode();
+                    node.deleteNode();
+                    node = next;
+                }
+            }
+            else if(NodeDao.state() != NodeDao.DaoState.Reading)
+            {
+                Nodeinfo data = getNodeInfo();
+    
+                data.setId(id);
+    
+                try 
+                {
+                    //id is primary key of node info, we can't modify the primary key by primary key, so it need delete first
+                    NodeDao.getCurrentMapper().insert(data);
+                    //delete
+                    if(defineded()) NodeDao.getCurrentMapper().deleteByPrimaryKey(this.id);
+                }
+                catch (IOException IOEx)
+                {
+                    //no mapper
+                    throw IOEx;
+                }
+                catch (Exception e)
+                {
+                    //sql errery
+                    return;
+                }
+            }
+            else
+            {
+                InitAfterLoad(id);
+            }
+            if(!defineded()) addLoadedNode(this);
+            this.id = id;
+        }
+    }
+
+    /**
+     * for override, invoke when load feom database
+     * @param id currectt id information
+     */
+    private void InitAfterLoad(long id)
+    {
+
+    }
+
+    /**
+     * convert to NodeInfo data
+     * @return Node info for sql upload
+     */
+    public Nodeinfo getNodeInfo()
+    {
+        //gen data for update database
+        Nodeinfo data = new Nodeinfo();
+        BasicNode node = null;
+        //node id
+        data.setId(getId());
+        //next element
+        node = getNextNode();
+        if(node != null && node.vaildity())data.setNextId(node.getId());
+        else data.setNextId(null);
+        //perv element
+        node = getPervNode();
+        if(node != null && node.vaildity())data.setPrevId(node.getId());
+        else data.setPrevId(null);
+        //parent element
+        node = getParentNode();
+        if(node != null && node.vaildity())data.setParentId(node.getId());
+        else data.setParentId(null);
+        //chile level
+        node = getChildLevel();
+        if(node != null && node.vaildity())
+        {
+            node = node.startOfNodeLevel();
+            data.setChildId(node.getId());
+        }
+        else data.setChildId(null);
+        //node class
+        data.setObjType(this.getClass().getName());
+        return data;
+    }
+
+    /**
+     * upload to database
+     * @throws IOException no mapper
+     */
+    public void uploadNode() throws IOException
+    {
+        synchronized(this)
+        {
+            if(needUpload)
+            {
+                Nodeinfo data = getNodeInfo();
+                NodeDao.getCurrentMapper().updateByPrimaryKey(data);
+                needUpload = false;
+            }
+        }
+    }
+
+    /**
+     * check node vaild
+     * @return if is false it should not exists in database
+     */
+    public boolean vaildity()
+    {
+        return getId() >= 0;
+    }
+
+    /**
+     * check id defined statue
+     * @return if is true, node id should defineded
+     */
+    public boolean defineded()
+    {
+        return getId() > 0;
+    }
+
+    /**
+     * InnerHTML of tab
+     * @return DOM Context.InnerHTML
+     */
+    public String tabContextInnerHTML()
+    {
+        return "id : " + getId();
+    }
+
+    /**
+     * remove itselfs from its level
+     */
+    public void dropFromLevel()
+    {
+        synchronized(this)
+        {
+            if(this.nextNode != null)
+            {
+                this.nextNode.pervNode = this.pervNode;
+                this.nextNode.needUpload = true;
+            }
+            if(this.pervNode != null)
+            {
+                this.pervNode.nextNode = this.nextNode;
+                this.pervNode.needUpload = true;
+            }
+            else
+            if(this.parentNode != null)
+            {
+                this.parentNode.childLevel = this.nextNode;
+                this.parentNode.needUpload = true;
+            }
+            this.parentNode = null;
+            this.nextNode = null;
+            this.pervNode = null;
+            this.needUpload = true;
+        }
+    }
+    
+    /**
+     * instert a {@link #node} after this node
+     * @param node node to instert/
+     */
+    public boolean insertNext(BasicNode node)
+    {
+        synchronized(this)
+        {
+            if(node != null && node.vaildity() && this.vaildity())
+            {
+                if(!node.subTreeContains(this))
+                {
+                    //remove from its level
+                    node.dropFromLevel();
+                    //cache
+                    BasicNode nextNode = this.nextNode;
+                    //replace next
+                    this.nextNode = node;
+                    node.nextNode = nextNode;
+                    //replace perv
+                    node.pervNode = this;
+                    //set to same parent node
+                    node.parentNode = this.parentNode;
+                    //check if exiet
+                    if(nextNode != null)
+                    {
+                        nextNode.pervNode = node;
+                        nextNode.needUpload = true;
+                    }
+    
+                    this.needUpload = true;
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * instert a {@link #node} before this node
+     * @param node node to instert
+     */
+    public boolean insertPerv(BasicNode node)
+    {
+        synchronized(this)
+        {
+            if(node != null && node.vaildity() && this.vaildity())
+            {
+                if(!node.subTreeContains(this))
+                {
+                    //remove from its level
+                    node.dropFromLevel();
+                    //cache
+                    BasicNode pervNode = this.pervNode;
+                    //replace next
+                    this.pervNode = node;
+                    node.pervNode = pervNode;
+                    //replace last
+                    node.nextNode = this;
+                    //set to same parent node
+                    node.parentNode = this.parentNode;
+                    //check if exiet
+                    if(pervNode != null)
+                    {
+                        pervNode.nextNode = node;
+                        pervNode.needUpload = true;
+                    }
+                    else //remove if parrentNode exiet
+                    if(this.parentNode != null)
+                    {
+                        this.parentNode.childLevel = node;
+                        this.parentNode.needUpload = true;
+                    }
+    
+                    this.needUpload = true;
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * replace current pos of its level
+     * @param node node for replace
+     */
+    public boolean replaceBy(BasicNode node)
+    {
+        synchronized(this)
+        {
+            if(!vaildity()) return false;
+            if(node != null && node.vaildity())
+            {
+                if(!node.subTreeContains(this))
+                {                
+                    node.dropFromLevel();
+                    node.parentNode = this.parentNode;
+                    node.nextNode = this.nextNode;
+                    node.pervNode = this.pervNode;
+                    this.dropFromLevel();
+                    if(node.nextNode != null)
+                    {
+                        node.nextNode.pervNode = node;
+                    }
+                    if(node.pervNode != null)
+                    {
+                        node.pervNode.nextNode = node;
+                    }
+                    else
+                    if(node.parentNode != null)
+                    {
+                        node.parentNode.childLevel = node;
+                        node.parentNode.needUpload = true;
+                    }
+                    return true;
+                }
+            }
+            else
+            {
+                this.dropFromLevel();
+                return true;
+            }
+            return false;
+        }
+    }
+
+
+    public boolean exchangeWith(BasicNode node)
+    {
+        synchronized(this)
+        {
+            if(!vaildity()) return false;
+            if(node != null && node.vaildity())
+            {
+                if(!node.subTreeContains(this) && !this.subTreeContains(node))
+                {
+                    //cache
+                    BasicNode next = node.nextNode;
+                    BasicNode perv = node.pervNode;
+                    BasicNode parent = node.parentNode;
+                    
+                    if(next == this)
+                    {
+                        next = this.pervNode;
+                        this.pervNode = this;
+                    }
+                    if(perv == this)
+                    {
+                        perv = this.nextNode;
+                        this.nextNode = this;
+                    }
+                    //set node to this
+                    node.nextNode = this.nextNode;
+                    node.pervNode = this.pervNode;
+                    node.parentNode = this.parentNode;
+                    node.needUpload = true;
+                    //check near by node update
+                    if(node.nextNode != null)
+                    {
+                        node.nextNode.pervNode = node;
+                        node.nextNode.needUpload = true;
+                    }
+                    if(node.pervNode != null)
+                    {
+                        node.pervNode.nextNode = node;
+                        node.pervNode.needUpload = true;
+                    }
+                    else
+                    if(node.parentNode != null)
+                    {
+                        node.parentNode.childLevel = node;
+                        node.parentNode.needUpload = true;
+                    }
+    
+                    //set this to next
+                    this.nextNode = next;
+                    this.pervNode = perv;
+                    this.parentNode = parent;
+                    this.needUpload = true;
+                    //check near by node update
+                    if(this.nextNode != null)
+                    {
+                        this.nextNode.pervNode = this;
+                        this.nextNode.needUpload = true;
+                    }
+                    if(this.pervNode != null)
+                    {
+                        this.pervNode.nextNode = this;
+                        this.pervNode.needUpload = true;
+                    }
+                    else
+                    if(this.parentNode != null)
+                    {
+                        this.parentNode.childLevel = this;
+                        this.parentNode.needUpload = true;
+                    }
+                    return true;
+                }
+            }
+            else
+            {
+                this.dropFromLevel();
+                return true;
+            }
+            return false;
+        }
+    }
+    
+    /**
+     * Level's start
+     */
+    public BasicNode startOfNodeLevel()
+    {
+        BasicNode node = this;
+        while(node.pervNode != null)
+        {
+            node = node.pervNode;
+        }
+        return node;
+    }
+    
+    /**
+     * Level's end
+     */
+    public BasicNode endOfNodeLevel()
+    {
+        BasicNode node = this;
+        while(node.nextNode != null)
+        {
+            node = node.nextNode;
+        }
+        return node;
+    }
+    
+    /**
+     * get root of node tree
+     * @return node of the minimum level
+     */
+    public BasicNode rootNode()
+    {
+        BasicNode node = this;
+        while(node.parentNode != null)
+        {
+            node = node.parentNode;
+        }
+        return node;
+    }
+
+    /**
+     * replace child level to {@link #childLevel}
+     * @param childLevel target
+     * @return if success , return droped node else null
+     */
+    public BasicNode setChildLevel(BasicNode childLevel)
+    {
+        //is use as level, so we need to 
+        if(childLevel != null && vaildity() && childLevel.vaildity())
+        {
+            //save usage
+            childLevel = childLevel.startOfNodeLevel();
+            if(childLevel.subTreeContains(this.startOfNodeLevel())) return null;
+            BasicNode result = this.childLevel;
+            if(childLevel != null)
+            {
+                for(BasicNode node : childLevel)
+                {
+                    node.parentNode = this;
+                }
+            }
+            if(this.childLevel != null)
+            {
+                for(BasicNode node : this.childLevel)
+                {
+                    node.parentNode = null;
+                }
+            }
+            this.childLevel = childLevel;
+            return result;
+        }
+        return null;
+    }
+
+    /**
+     * check if level contains {@ling #node}
+     * @param node node for check
+     * @return {@value true} mean contains {@value false} mean not contains
+     */
+    public boolean levelContains(BasicNode node)
+    {
+        if(node != null)
+        {
+            if(node.parentNode != null && this.parentNode != null)
+            {
+                return node.parentNode == this.parentNode;
+            }
+            else
+            {
+                BasicNode cache1 = node;
+                BasicNode cache2 = this;
+                do
+                {
+                    //check 2 node's perv node at same time
+                    if(cache1 == this || cache2 == node)
+                        return true;
+                    if(cache1.pervNode != null)
+                        cache1 = cache1.pervNode;
+                    if(cache2.pervNode != null)
+                        cache2 = cache2.pervNode;
+                }
+                while(cache2.pervNode != null || cache1.pervNode != null);
+                return cache1 == cache2;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * check if node tree has node
+     * @param node node for check
+     * @return {@value true} mean contains {@value false} mean not contains
+     */
+    public boolean treeContains(BasicNode node)
+    {
+        if(node != null)
+        {
+            return node.rootNode().levelContains(this.rootNode());
+        }
+        return false;
+    }
+
+    /**
+     * check if this node is a sub node of the node
+     * @param node node for check
+     * @return if this node is a sub node of the node, it will return true 
+     */
+    public boolean subTreeContains(BasicNode node)
+    {
+        if(node != null)
+        {
+            do
+            {
+                if(node == this)
+                {
+                    return true;
+                }
+                node = node.parentNode;
+            }
+            while(node != null);
+        }
+        return false;
+    }
+
+
+    public long getLayout()
+    {
+        long result = 0;
+        BasicNode node =this.getParentNode();
+        while(node != null)
+        {
+            node = node.getParentNode();
+            ++result;
+        }
+        return result;
+    }
+    
+
+    @Override
+    public String toString() 
+    {
+        String result = this.getId() + "{ ";
+        for(BasicNode node : this)
+        {
+            result += node.getId();
+            if(node.getChildLevel() != null) result += "+";
+            if(node.nextNode != null) result += " , ";
+        }
+        return result + " }";
+    }
+
+
+    public void deleteNode() throws IOException
+    {
+        this.setId(-1l);
+    }
+
+
+    private static void addLoadedNode(BasicNode node)
+    {
+        for (ArrayList<BasicNode> list : loadedNodes)
+        {
+            if(list.size() < Integer.MAX_VALUE)
+            {
+                list.add(node);
+                return;
+            }
+        }
+        ArrayList<BasicNode> nodes = new ArrayList<BasicNode>();
+        nodes.add(node);
+        loadedNodes.add(nodes);
+    }
+
+
+    private static void removeLoadedNode(BasicNode node)
+    {
+        for (int i = 0; i < loadedNodes.size(); ++i)
+        {
+            ArrayList<BasicNode> list = loadedNodes.get(i);
+            list.remove(node);
+            if(list.size() <= 0)
+            {
+                loadedNodes.remove(i);
+                --i;
+            }
+        }
+    }
+
+    /**
+     * find node from node pool, if target is not exiets, it will return null
+     * @param id target id
+     * @return target
+     */
+    public static BasicNode getLoadedNodeById(long id)
+    {
+        for (ArrayList<BasicNode> list : loadedNodes)
+        {
+            for (BasicNode basicNode : list)
+            {
+                if(basicNode.getId() == id)
+                {
+                    return basicNode;
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * check level
+     * @param levelA value a
+     * @param levelB value b
+     * @return if is same level,it will return true
+     */
+    public static boolean levelEqul(BasicNode levelA,BasicNode levelB)
+    {
+        return levelA.startOfNodeLevel() == levelB.startOfNodeLevel();
+    }
+
+    /**
+     * check all loaded node and upload data
+     * @throws IOException no sql mapper
+     */
+    public static void checkAndUploadAll() throws IOException
+    {
+        for (ArrayList<BasicNode> list : loadedNodes)
+        {
+            for (BasicNode basicNode : list)
+            {
+                if(basicNode.needUpload)
+                {
+                    basicNode.uploadNode();
+                }
+            }
+        }
+        NodeDao.getCurrentMapper().commit();
+    }
+
+    /**
+     * Iterator of {@link #BasicNode}
+     */
+    class NodeIterator implements Iterator<BasicNode>
+    {
+        BasicNode next;
+        private NodeIterator(BasicNode node)
+        {
+            next = node;
+        }
+
+        @Override
+        public boolean hasNext() {
+            return next != null;
+        }
+        
+        @Override
+        public BasicNode next() {
+            BasicNode next = this.next;
+            this.next = next.nextNode;
+            return next;
+        }
+    }
+
+}

+ 144 - 0
src/main/java/group04/NodeDao.java

@@ -0,0 +1,144 @@
+package group04;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import group04.myBatis.Nodeinfo;
+import group04.myBatis.NodeinfoMapper;
+
+@Service
+public class NodeDao
+{
+
+    public NodeDao()
+    {
+        current = this;
+    }
+
+    @Autowired
+    NodeinfoMapper nodeinfoMapper;
+    
+    static {
+        System.setProperty("druid.mysql.usePingMethod","false");
+    }
+
+    public static NodeinfoMapper getCurrentMapper() throws IOException
+    {
+        if(current != null)
+            return current.nodeinfoMapper;
+        else
+        throw new IOException("mapper hasent been initlized");
+    }
+
+    /**
+     * load the tree that contains an node of this id, and get that node of the tree.
+     * @param id target
+     * @return node of id in tree
+     * @throws IOException no sql mapper
+     */
+    public static BasicNode loadNodeTreeById(long id) throws IOException
+    {
+        BasicNode result = null;
+        if(id > 0)
+        {
+            result = BasicNode.getLoadedNodeById(id);
+            if(result == null)
+            {
+                daoState = DaoState.Reading;
+                try
+                {
+                    Nodeinfo data = getCurrentMapper().selectByPrimaryKey(id);
+                    if(data != null)
+                    {
+                        while(data.getParentId() != null)
+                        {
+                            Nodeinfo cache = data;
+                            data = getCurrentMapper().selectByPrimaryKey(data.getParentId());
+                            if(data == null)
+                            {
+                                data = cache;
+                                break;
+                            }
+                        }
+                        while(data.getPrevId() != null)
+                        {
+                            Nodeinfo cache = data;
+                            data = getCurrentMapper().selectByPrimaryKey(data.getPrevId());
+                            if(data == null)
+                            {
+                                data = cache;
+                                break;
+                            }
+                        }
+                        loadAllInLevel(data);
+                    }
+                }
+                catch(Exception ex)
+                {
+                    System.out.println(ex.toString());
+                    return null;
+                }
+                result = BasicNode.getLoadedNodeById(id);
+                daoState = DaoState.None;
+            }
+        }
+        return result;
+    }
+
+    private static BasicNode loadAllInLevel(Nodeinfo nodeinfo) throws IOException
+    {
+        if(nodeinfo != null)
+        {
+            daoState = DaoState.Reading;
+            try {
+                ArrayList<BasicNode> nodes = new ArrayList<>();
+                ArrayList<Nodeinfo> infos = new ArrayList<>();
+                do
+                {
+                    infos.add(getCurrentMapper().selectByPrimaryKey(nodeinfo.getChildId()));
+                    BasicNode node = (BasicNode)Class.forName(nodeinfo.getObjType()).getConstructor().newInstance();
+                    node.setId(nodeinfo.getId());
+                    nodes.add(node);
+                    nodeinfo = getCurrentMapper().selectByPrimaryKey(nodeinfo.getNextId());
+                }
+                while(nodeinfo != null);
+                int sizeMOne = nodes.size() - 1;
+                for(int i = 0; i < nodes.size(); ++i)
+                {
+                    if(i < sizeMOne)
+                    {
+                        nodes.get(i).insertNext(nodes.get(i + 1));
+                    }
+                    nodes.get(i).setChildLevel(loadAllInLevel(infos.get(i)));
+                }
+                return nodes.get(0);
+            } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
+                    | NoSuchMethodException | SecurityException | ClassNotFoundException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
+            }
+        }
+        return null;
+    }
+
+    public static DaoState state()
+    {
+        return daoState;
+    }
+
+    private static DaoState daoState = DaoState.None;
+
+    private static NodeDao current;
+    
+    enum DaoState
+    {
+        None,
+        Reading,
+        ResoveRef,
+        Write
+    }
+}

+ 195 - 0
src/main/java/group04/myBatis/Nodeinfo.java

@@ -0,0 +1,195 @@
+package group04.myBatis;
+
+public class Nodeinfo {
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column nodeinfo.id
+     *
+     * @mbggenerated
+     */
+    private Long id;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column nodeinfo.prev_id
+     *
+     * @mbggenerated
+     */
+    private Long prevId;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column nodeinfo.next_id
+     *
+     * @mbggenerated
+     */
+    private Long nextId;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column nodeinfo.parent_id
+     *
+     * @mbggenerated
+     */
+    private Long parentId;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column nodeinfo.child_id
+     *
+     * @mbggenerated
+     */
+    private Long childId;
+
+    /**
+     * This field was generated by MyBatis Generator.
+     * This field corresponds to the database column nodeinfo.obj_type
+     *
+     * @mbggenerated
+     */
+    private String objType;
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column nodeinfo.id
+     *
+     * @return the value of nodeinfo.id
+     *
+     * @mbggenerated
+     */
+    public Long getId() {
+        return id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column nodeinfo.id
+     *
+     * @param id the value for nodeinfo.id
+     *
+     * @mbggenerated
+     */
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column nodeinfo.prev_id
+     *
+     * @return the value of nodeinfo.prev_id
+     *
+     * @mbggenerated
+     */
+    public Long getPrevId() {
+        return prevId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column nodeinfo.prev_id
+     *
+     * @param prevId the value for nodeinfo.prev_id
+     *
+     * @mbggenerated
+     */
+    public void setPrevId(Long prevId) {
+        this.prevId = prevId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column nodeinfo.next_id
+     *
+     * @return the value of nodeinfo.next_id
+     *
+     * @mbggenerated
+     */
+    public Long getNextId() {
+        return nextId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column nodeinfo.next_id
+     *
+     * @param nextId the value for nodeinfo.next_id
+     *
+     * @mbggenerated
+     */
+    public void setNextId(Long nextId) {
+        this.nextId = nextId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column nodeinfo.parent_id
+     *
+     * @return the value of nodeinfo.parent_id
+     *
+     * @mbggenerated
+     */
+    public Long getParentId() {
+        return parentId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column nodeinfo.parent_id
+     *
+     * @param parentId the value for nodeinfo.parent_id
+     *
+     * @mbggenerated
+     */
+    public void setParentId(Long parentId) {
+        this.parentId = parentId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column nodeinfo.child_id
+     *
+     * @return the value of nodeinfo.child_id
+     *
+     * @mbggenerated
+     */
+    public Long getChildId() {
+        return childId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column nodeinfo.child_id
+     *
+     * @param childId the value for nodeinfo.child_id
+     *
+     * @mbggenerated
+     */
+    public void setChildId(Long childId) {
+        this.childId = childId;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method returns the value of the database column nodeinfo.obj_type
+     *
+     * @return the value of nodeinfo.obj_type
+     *
+     * @mbggenerated
+     */
+    public String getObjType() {
+        return objType;
+    }
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method sets the value of the database column nodeinfo.obj_type
+     *
+     * @param objType the value for nodeinfo.obj_type
+     *
+     * @mbggenerated
+     */
+    public void setObjType(String objType) {
+        this.objType = objType;
+    }
+}

+ 55 - 0
src/main/java/group04/myBatis/NodeinfoMapper.java

@@ -0,0 +1,55 @@
+package group04.myBatis;
+
+public interface NodeinfoMapper {
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table nodeinfo
+     *
+     * @mbggenerated
+     */
+    int deleteByPrimaryKey(Long id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table nodeinfo
+     *
+     * @mbggenerated
+     */
+    int insert(Nodeinfo record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table nodeinfo
+     *
+     * @mbggenerated
+     */
+    int insertSelective(Nodeinfo record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table nodeinfo
+     *
+     * @mbggenerated
+     */
+    Nodeinfo selectByPrimaryKey(Long id);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table nodeinfo
+     *
+     * @mbggenerated
+     */
+    int updateByPrimaryKeySelective(Nodeinfo record);
+
+    /**
+     * This method was generated by MyBatis Generator.
+     * This method corresponds to the database table nodeinfo
+     *
+     * @mbggenerated
+     */
+    int updateByPrimaryKey(Nodeinfo record);
+
+
+
+    int commit();
+}

+ 227 - 0
src/main/java/group04/nodeOptConsol.java

@@ -0,0 +1,227 @@
+package group04;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.Arrays;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class nodeOptConsol {
+
+    public static BasicNode current = null;
+
+    private static ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("springmvc-config.xml");
+
+    public static ClassPathXmlApplicationContext getContext()
+    {
+        return context;
+    }
+
+    public static void main(String[] args) throws IOException {
+        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
+        //nums.add(1);
+        String command = "";
+        while(true)
+        {
+            try 
+            {
+                if(current != null) System.out.print(current.getClass() + "#" + current.getId());
+                System.out.print(">");
+                command = br.readLine();
+            } 
+            catch (Exception e) 
+            {
+                System.out.println("errer : " + e.toString());
+            }
+            String[] prams = command.split(" ");
+            command = prams[0];
+            if(prams.length > 1)
+            {
+                prams = Arrays.copyOfRange(prams, 1, prams.length);
+            }
+            // System.out.println(command);
+            switch(command.toLowerCase())
+            {
+                //select node from database or loaded node
+                case "sel":
+                if(prams.length > 0)
+                {
+                    try
+                    {
+                        long id = Long.valueOf(prams[0]);
+                        current = NodeDao.loadNodeTreeById(id);
+                    }
+                    catch(NumberFormatException ex)
+                    {
+                        System.out.println("can't id press to number");
+                    }
+                }
+                break;
+                case "log":
+                System.out.println(current);
+                break;
+                //parent node
+                case "par":
+                if(current != null) current = current.getParentNode();
+                break;
+                //list node
+                case "ls":
+                if(current != null) System.out.println(current.getChildLevel());
+                else System.out.println("null");
+                break;
+                //move node to
+                case "mov":
+                if(prams.length > 0)
+                {
+                    try
+                    {
+                        long id = Long.valueOf(prams[0]);
+
+                        BasicNode target = NodeDao.loadNodeTreeById(id);
+                        if(target != null)
+                        {
+                            if(prams.length > 1)
+                            {
+                                switch(prams[1].toLowerCase())
+                                {
+                                    //next of target
+                                    case "/n":
+                                    target.insertNext(current);
+                                    break;
+                                    //previous node of target
+                                    case "/p":
+                                    target.insertPerv(current);
+                                    break;
+                                }
+                            }
+                            else
+                            {
+                                target.insertNext(current);
+                            }
+                        }
+                    }
+                    catch(NumberFormatException ex)
+                    {
+                        System.out.println("can't id press to number");
+                    }
+                }
+                break;
+                //replace node
+                case "rp":
+                if(prams.length > 0)
+                {
+                    try
+                    {
+                        long id = Long.valueOf(prams[0]);
+                        BasicNode target = NodeDao.loadNodeTreeById(id);
+                        if(target != null)
+                        {
+                            if(prams.length > 1)
+                            {
+                                switch(prams[1].toLowerCase())
+                                {
+                                    //replace current
+                                    case "/c":
+                                    current.replaceBy(target);
+                                    current = target;
+                                    break;
+                                    //replace target
+                                    case "/t":
+                                    target.replaceBy(current);
+                                    break;
+                                    case "/e":
+                                    current.exchangeWith(target);
+                                    break;
+                                }
+                            }
+                            else
+                            {
+                                current.replaceBy(target);
+                                current = target;
+                            }
+                        }
+                    }
+                    catch(NumberFormatException ex)
+                    {
+                        System.out.println("can't id press to number");
+                    }
+                }
+                break;
+                //create node
+                case "new":
+                if(prams.length > 0)
+                {
+                    try
+                    {
+                        long id = Long.valueOf(prams[0]);
+                        BasicNode newNode = new BasicNode(id);
+                        if(newNode.defineded()) current = newNode;
+                    }
+                    catch(NumberFormatException ex)
+                    {
+                        System.out.println("can't id press to number");
+                    }
+                }
+                break;
+                case "del":
+                if(current != null) current.deleteNode();
+                current = null;
+                break;
+                //set level parent node
+                case "slp":
+                if(prams.length > 0)
+                {
+                    try
+                    {
+                        long id = Long.valueOf(prams[0]);
+                        BasicNode target = NodeDao.loadNodeTreeById(id);
+                        if(target != null)
+                        {
+                            target.setChildLevel(current);
+                        }
+                    }
+                    catch(NumberFormatException ex)
+                    {
+                        System.out.println("can't id press to number");
+                    }
+                }
+                break;
+                //join child level
+                case "jcl":
+                if(prams.length > 0)
+                {
+                    try
+                    {
+                        long id = Long.valueOf(prams[0]);
+                        BasicNode target = NodeDao.loadNodeTreeById(id);
+                        if(target != null)
+                        {
+                            if(target.getChildLevel() == null)
+                            {
+                                if(current != null)
+                                {
+                                    current.dropFromLevel();
+                                    target.setChildLevel(current);
+                                }
+                            }
+                            else
+                            {
+                                target.getChildLevel().endOfNodeLevel().insertNext(current);
+                            }
+                        }
+                    }
+                    catch(NumberFormatException ex)
+                    {
+                        System.out.println("can't id press to number");
+                    }
+                }
+                break;
+                case "ex":
+                BasicNode.checkAndUploadAll();
+                return;
+            }
+        }
+    }
+    
+}

+ 80 - 0
src/main/resources/DataBase.sql

@@ -0,0 +1,80 @@
+create database if not exists ShoppingWebsite;
+use ShoppingWebsite;
+
+
+
+/*  node stuctor
+    userAccount
+    +   user_cart
+    +   user_collect
+*/
+create table if not exists userAccount
+(
+    userId bigint not null,
+    email varchar(50) not null,
+    password varchar(16) not null,
+    permission int not null default 0,
+    primary key(email,userId)
+);
+
+create table if not exists user_cart
+(
+    user_Cart_Id bigint not null primary key,
+    password varchar(16) not null,
+    permission int not null default 0,
+);
+
+create table if not exists user_collect
+(
+    user_collect_Id bigint not null primary key,
+    password varchar(16) not null,
+    permission int not null default 0,
+);
+
+
+/*  node stuctor
+    store
+    +   goods
+        +   selectionGroup
+            +   selection
+*/
+create table if not exists store
+(
+    store_Id bigint not null primary key,
+    postion varchar(100) not null,
+    name varchar(50) not null,
+    star int
+)
+
+create table if not exists goods
+(
+    goods_id bigint not null primary key,
+    postion varchar(100) not null,
+    name varchar(50) not null,
+    star int
+)
+
+create table if not exists selectionGroup
+(
+    selection_group_id bigint not null primary key,
+    name varchar(50) not null,
+)
+
+create table if not exists selection
+(
+    selection_id bigint not null primary key,
+    name varchar(50) not null,
+    price float(13,2)
+)
+
+
+/*  node*/
+create table if not exists nodeinfo
+(
+    id bigint not null primary key,
+    prev_id bigint null,
+    next_id bigint null,
+    parent_id bigint null,
+    child_id bigint null,
+    obj_type varchar(100) default 'group04.BasicNode'
+);

+ 27 - 0
src/main/resources/MyBatis-config.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <settings>
+        <setting name="mapUnderscoreToCamelCase" value="true"/>
+    </settings>
+<!--    <typeAliases>-->
+<!--        <package name="myBatisTest.myBatis"/>-->
+<!--    </typeAliases>-->
+<!--    <environments default="development">-->
+<!--        <environment id="development">-->
+<!--            <transactionManager type="JDBC"/>-->
+<!--            <dataSource type="POOLED">-->
+<!--                <property name="driver" value="com.mysql.jdbc.Driver"/>-->
+<!--                <property name="url" value="jdbc:mysql://localhost:3306/user"/>-->
+<!--                <property name="username" value="root"/>-->
+<!--                <property name="password" value="123456"/>-->
+<!--            </dataSource>-->
+<!--        </environment>-->
+<!--    </environments>-->
+    <mappers>
+        <mapper resource="myBatisMap/NodeinfoMapper.xml"/>
+<!--        <mapper resource="StuMapper.xml"/>-->
+    </mappers>
+</configuration>

+ 4 - 0
src/main/resources/db.properties

@@ -0,0 +1,4 @@
+jdbc.driver=com.mysql.jdbc.Driver
+jdbc.url=jdbc:mysql://localhost:3306/dsnodetree
+jdbc.username=root
+jdbc.password=123456

+ 43 - 0
src/main/resources/generatorConfig.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE generatorConfiguration PUBLIC
+        "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+<generatorConfiguration>
+    <classPathEntry location="C:\Users\16096\.m2\repository\mysql\mysql-connector-java\8.0.23\mysql-connector-java-8.0.23.jar"/>
+    <context id="context" targetRuntime="MyBatis3">
+        <commentGenerator>
+            <property name="suppressAllComment" value="false"/>
+            <property name="suppressDate" value="true"/>
+        </commentGenerator>
+        <jdbcConnection
+                driverClass="com.mysql.jdbc.Driver"
+                connectionURL="jdbc:mysql://localhost:3306/dsnodetree"
+                userId="root"
+                password="123456"
+        />
+        <javaTypeResolver>
+            <property name="forceBigDecimals" value="false"/>
+        </javaTypeResolver>
+
+        <javaModelGenerator targetPackage="group04.myBatis" targetProject="src/main/java">
+            <property name="enableSubPackages" value="true"/>
+            <property name="trimStrings" value="false"/>
+        </javaModelGenerator>
+
+        <sqlMapGenerator targetPackage="myBatisMap" targetProject="src/main/resources">
+            <property name="enableSubPackages" value="true"/>
+        </sqlMapGenerator>
+
+        <javaClientGenerator targetPackage="group04.myBatis" targetProject="src/main/java" type="XMLMAPPER">
+            <property name="enableSubPackages" value="true"/>
+        </javaClientGenerator>
+
+        <table
+                tableName="nodeinfo"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+    </context>
+</generatorConfiguration>

+ 141 - 0
src/main/resources/myBatisMap/NodeinfoMapper.xml

@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="group04.myBatis.NodeinfoMapper" >
+  <resultMap id="BaseResultMap" type="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <id column="id" property="id" jdbcType="BIGINT" />
+    <result column="prev_id" property="prevId" jdbcType="BIGINT" />
+    <result column="next_id" property="nextId" jdbcType="BIGINT" />
+    <result column="parent_id" property="parentId" jdbcType="BIGINT" />
+    <result column="child_id" property="childId" jdbcType="BIGINT" />
+    <result column="obj_type" property="objType" jdbcType="VARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    id, prev_id, next_id, parent_id, child_id, obj_type
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from nodeinfo
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    delete from nodeinfo
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <insert id="insert" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    insert into nodeinfo (id, prev_id, next_id, 
+      parent_id, child_id, obj_type
+      )
+    values (#{id,jdbcType=BIGINT}, #{prevId,jdbcType=BIGINT}, #{nextId,jdbcType=BIGINT}, 
+      #{parentId,jdbcType=BIGINT}, #{childId,jdbcType=BIGINT}, #{objType,jdbcType=VARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    insert into nodeinfo
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        id,
+      </if>
+      <if test="prevId != null" >
+        prev_id,
+      </if>
+      <if test="nextId != null" >
+        next_id,
+      </if>
+      <if test="parentId != null" >
+        parent_id,
+      </if>
+      <if test="childId != null" >
+        child_id,
+      </if>
+      <if test="objType != null" >
+        obj_type,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="prevId != null" >
+        #{prevId,jdbcType=BIGINT},
+      </if>
+      <if test="nextId != null" >
+        #{nextId,jdbcType=BIGINT},
+      </if>
+      <if test="parentId != null" >
+        #{parentId,jdbcType=BIGINT},
+      </if>
+      <if test="childId != null" >
+        #{childId,jdbcType=BIGINT},
+      </if>
+      <if test="objType != null" >
+        #{objType,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update nodeinfo
+    <set >
+      <if test="prevId != null" >
+        prev_id = #{prevId,jdbcType=BIGINT},
+      </if>
+      <if test="nextId != null" >
+        next_id = #{nextId,jdbcType=BIGINT},
+      </if>
+      <if test="parentId != null" >
+        parent_id = #{parentId,jdbcType=BIGINT},
+      </if>
+      <if test="childId != null" >
+        child_id = #{childId,jdbcType=BIGINT},
+      </if>
+      <if test="objType != null" >
+        obj_type = #{objType,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update nodeinfo
+    set prev_id = #{prevId,jdbcType=BIGINT},
+      next_id = #{nextId,jdbcType=BIGINT},
+      parent_id = #{parentId,jdbcType=BIGINT},
+      child_id = #{childId,jdbcType=BIGINT},
+      obj_type = #{objType,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="commit">
+    commit
+  </update>
+</mapper>

+ 55 - 0
src/main/resources/springmvc-config.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:mvc="http://www.springframework.org/schema/mvc"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/context
+       http://www.springframework.org/schema/context/spring-context.xsd
+       http://www.springframework.org/schema/mvc
+       http://www.springframework.org/schema/mvc/spring-mvc.xsd">
+    <context:property-placeholder location="classpath:db.properties"/>
+
+    <context:component-scan base-package="group04"/>
+
+    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
+        <property name="driverClassName" value="${jdbc.driver}"/>
+        <property name="url" value="${jdbc.url}"/>
+        <property name="username" value="${jdbc.username}"/>
+        <property name="password"  value="${jdbc.password}"/>
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:MyBatis-config.xml"/>
+    </bean>
+
+    <!--MyBatis Mapper FactoryBean-->
+    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+        <property name="basePackage" value="group04.myBatis"/>
+    </bean>
+
+    <!--Spring MVC.....(for primary web service)-->
+    <!-- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+        <property name="prefix" value = "/"/>
+        <property name="suffix" value = ".jsp"/>
+    </bean> -->
+
+    <!-- should add multipartResolver to use  -->
+    <!-- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
+        <property name="defaultEncoding" value="utf-8"/>
+        <property name="maxUploadSize" value="2097152"/>
+    </bean> -->
+
+    <!-- <mvc:annotation-driven/>
+    <mvc:default-servlet-handler/> -->
+    <!--    <mvc:interceptors>-->
+    <!--        <mvc:interceptor>-->
+    <!--            <mvc:mapping path="/*"/>-->
+    <!--            <mvc:exclude-mapping path="/LoginPage"/>-->
+    <!--            <bean id="InterceptorLogin" class="MVCTry.InterceptorLogin"/>-->
+    <!--        </mvc:interceptor>-->
+    <!--    </mvc:interceptors>-->
+</beans>

+ 80 - 0
target/classes/DataBase.sql

@@ -0,0 +1,80 @@
+create database if not exists ShoppingWebsite;
+use ShoppingWebsite;
+
+
+
+/*  node stuctor
+    userAccount
+    +   user_cart
+    +   user_collect
+*/
+create table if not exists userAccount
+(
+    userId bigint not null,
+    email varchar(50) not null,
+    password varchar(16) not null,
+    permission int not null default 0,
+    primary key(email,userId)
+);
+
+create table if not exists user_cart
+(
+    user_Cart_Id bigint not null primary key,
+    password varchar(16) not null,
+    permission int not null default 0,
+);
+
+create table if not exists user_collect
+(
+    user_collect_Id bigint not null primary key,
+    password varchar(16) not null,
+    permission int not null default 0,
+);
+
+
+/*  node stuctor
+    store
+    +   goods
+        +   selectionGroup
+            +   selection
+*/
+create table if not exists store
+(
+    store_Id bigint not null primary key,
+    postion varchar(100) not null,
+    name varchar(50) not null,
+    star int
+)
+
+create table if not exists goods
+(
+    goods_id bigint not null primary key,
+    postion varchar(100) not null,
+    name varchar(50) not null,
+    star int
+)
+
+create table if not exists selectionGroup
+(
+    selection_group_id bigint not null primary key,
+    name varchar(50) not null,
+)
+
+create table if not exists selection
+(
+    selection_id bigint not null primary key,
+    name varchar(50) not null,
+    price float(13,2)
+)
+
+
+/*  node*/
+create table if not exists nodeinfo
+(
+    id bigint not null primary key,
+    prev_id bigint null,
+    next_id bigint null,
+    parent_id bigint null,
+    child_id bigint null,
+    obj_type varchar(100) default 'group04.BasicNode'
+);

+ 27 - 0
target/classes/MyBatis-config.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE configuration
+        PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-config.dtd">
+<configuration>
+    <settings>
+        <setting name="mapUnderscoreToCamelCase" value="true"/>
+    </settings>
+<!--    <typeAliases>-->
+<!--        <package name="myBatisTest.myBatis"/>-->
+<!--    </typeAliases>-->
+<!--    <environments default="development">-->
+<!--        <environment id="development">-->
+<!--            <transactionManager type="JDBC"/>-->
+<!--            <dataSource type="POOLED">-->
+<!--                <property name="driver" value="com.mysql.jdbc.Driver"/>-->
+<!--                <property name="url" value="jdbc:mysql://localhost:3306/user"/>-->
+<!--                <property name="username" value="root"/>-->
+<!--                <property name="password" value="123456"/>-->
+<!--            </dataSource>-->
+<!--        </environment>-->
+<!--    </environments>-->
+    <mappers>
+        <mapper resource="myBatisMap/NodeinfoMapper.xml"/>
+<!--        <mapper resource="StuMapper.xml"/>-->
+    </mappers>
+</configuration>

BIN
target/classes/WebsiteES/WebApp.class


+ 4 - 0
target/classes/db.properties

@@ -0,0 +1,4 @@
+jdbc.driver=com.mysql.jdbc.Driver
+jdbc.url=jdbc:mysql://localhost:3306/dsnodetree
+jdbc.username=root
+jdbc.password=123456

+ 43 - 0
target/classes/generatorConfig.xml

@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE generatorConfiguration PUBLIC
+        "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
+        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
+<generatorConfiguration>
+    <classPathEntry location="C:\Users\16096\.m2\repository\mysql\mysql-connector-java\8.0.23\mysql-connector-java-8.0.23.jar"/>
+    <context id="context" targetRuntime="MyBatis3">
+        <commentGenerator>
+            <property name="suppressAllComment" value="false"/>
+            <property name="suppressDate" value="true"/>
+        </commentGenerator>
+        <jdbcConnection
+                driverClass="com.mysql.jdbc.Driver"
+                connectionURL="jdbc:mysql://localhost:3306/dsnodetree"
+                userId="root"
+                password="123456"
+        />
+        <javaTypeResolver>
+            <property name="forceBigDecimals" value="false"/>
+        </javaTypeResolver>
+
+        <javaModelGenerator targetPackage="group04.myBatis" targetProject="src/main/java">
+            <property name="enableSubPackages" value="true"/>
+            <property name="trimStrings" value="false"/>
+        </javaModelGenerator>
+
+        <sqlMapGenerator targetPackage="myBatisMap" targetProject="src/main/resources">
+            <property name="enableSubPackages" value="true"/>
+        </sqlMapGenerator>
+
+        <javaClientGenerator targetPackage="group04.myBatis" targetProject="src/main/java" type="XMLMAPPER">
+            <property name="enableSubPackages" value="true"/>
+        </javaClientGenerator>
+
+        <table
+                tableName="nodeinfo"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+    </context>
+</generatorConfiguration>

BIN
target/classes/group04/BasicNode$NodeIterator.class


BIN
target/classes/group04/BasicNode.class


BIN
target/classes/group04/NodeDao$DaoState.class


BIN
target/classes/group04/NodeDao.class


BIN
target/classes/group04/myBatis/Nodeinfo.class


BIN
target/classes/group04/myBatis/NodeinfoMapper.class


BIN
target/classes/group04/nodeOptConsol.class


+ 141 - 0
target/classes/myBatisMap/NodeinfoMapper.xml

@@ -0,0 +1,141 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
+<mapper namespace="group04.myBatis.NodeinfoMapper" >
+  <resultMap id="BaseResultMap" type="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    <id column="id" property="id" jdbcType="BIGINT" />
+    <result column="prev_id" property="prevId" jdbcType="BIGINT" />
+    <result column="next_id" property="nextId" jdbcType="BIGINT" />
+    <result column="parent_id" property="parentId" jdbcType="BIGINT" />
+    <result column="child_id" property="childId" jdbcType="BIGINT" />
+    <result column="obj_type" property="objType" jdbcType="VARCHAR" />
+  </resultMap>
+  <sql id="Base_Column_List" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    id, prev_id, next_id, parent_id, child_id, obj_type
+  </sql>
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    select 
+    <include refid="Base_Column_List" />
+    from nodeinfo
+    where id = #{id,jdbcType=BIGINT}
+  </select>
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    delete from nodeinfo
+    where id = #{id,jdbcType=BIGINT}
+  </delete>
+  <insert id="insert" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    insert into nodeinfo (id, prev_id, next_id, 
+      parent_id, child_id, obj_type
+      )
+    values (#{id,jdbcType=BIGINT}, #{prevId,jdbcType=BIGINT}, #{nextId,jdbcType=BIGINT}, 
+      #{parentId,jdbcType=BIGINT}, #{childId,jdbcType=BIGINT}, #{objType,jdbcType=VARCHAR}
+      )
+  </insert>
+  <insert id="insertSelective" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    insert into nodeinfo
+    <trim prefix="(" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        id,
+      </if>
+      <if test="prevId != null" >
+        prev_id,
+      </if>
+      <if test="nextId != null" >
+        next_id,
+      </if>
+      <if test="parentId != null" >
+        parent_id,
+      </if>
+      <if test="childId != null" >
+        child_id,
+      </if>
+      <if test="objType != null" >
+        obj_type,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides="," >
+      <if test="id != null" >
+        #{id,jdbcType=BIGINT},
+      </if>
+      <if test="prevId != null" >
+        #{prevId,jdbcType=BIGINT},
+      </if>
+      <if test="nextId != null" >
+        #{nextId,jdbcType=BIGINT},
+      </if>
+      <if test="parentId != null" >
+        #{parentId,jdbcType=BIGINT},
+      </if>
+      <if test="childId != null" >
+        #{childId,jdbcType=BIGINT},
+      </if>
+      <if test="objType != null" >
+        #{objType,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKeySelective" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update nodeinfo
+    <set >
+      <if test="prevId != null" >
+        prev_id = #{prevId,jdbcType=BIGINT},
+      </if>
+      <if test="nextId != null" >
+        next_id = #{nextId,jdbcType=BIGINT},
+      </if>
+      <if test="parentId != null" >
+        parent_id = #{parentId,jdbcType=BIGINT},
+      </if>
+      <if test="childId != null" >
+        child_id = #{childId,jdbcType=BIGINT},
+      </if>
+      <if test="objType != null" >
+        obj_type = #{objType,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="updateByPrimaryKey" parameterType="group04.myBatis.Nodeinfo" >
+    <!--
+      WARNING - @mbggenerated
+      This element is automatically generated by MyBatis Generator, do not modify.
+    -->
+    update nodeinfo
+    set prev_id = #{prevId,jdbcType=BIGINT},
+      next_id = #{nextId,jdbcType=BIGINT},
+      parent_id = #{parentId,jdbcType=BIGINT},
+      child_id = #{childId,jdbcType=BIGINT},
+      obj_type = #{objType,jdbcType=VARCHAR}
+    where id = #{id,jdbcType=BIGINT}
+  </update>
+  <update id="commit">
+    commit
+  </update>
+</mapper>

+ 55 - 0
target/classes/springmvc-config.xml

@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:mvc="http://www.springframework.org/schema/mvc"
+       xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans
+       http://www.springframework.org/schema/beans/spring-beans.xsd
+       http://www.springframework.org/schema/context
+       http://www.springframework.org/schema/context/spring-context.xsd
+       http://www.springframework.org/schema/mvc
+       http://www.springframework.org/schema/mvc/spring-mvc.xsd">
+    <context:property-placeholder location="classpath:db.properties"/>
+
+    <context:component-scan base-package="group04"/>
+
+    <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
+        <property name="driverClassName" value="${jdbc.driver}"/>
+        <property name="url" value="${jdbc.url}"/>
+        <property name="username" value="${jdbc.username}"/>
+        <property name="password"  value="${jdbc.password}"/>
+    </bean>
+
+    <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
+        <property name="dataSource" ref="dataSource" />
+        <property name="configLocation" value="classpath:MyBatis-config.xml"/>
+    </bean>
+
+    <!--MyBatis Mapper FactoryBean-->
+    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
+        <property name="basePackage" value="group04.myBatis"/>
+    </bean>
+
+    <!--Spring MVC.....(for primary web service)-->
+    <!-- <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+        <property name="prefix" value = "/"/>
+        <property name="suffix" value = ".jsp"/>
+    </bean> -->
+
+    <!-- should add multipartResolver to use  -->
+    <!-- <bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
+        <property name="defaultEncoding" value="utf-8"/>
+        <property name="maxUploadSize" value="2097152"/>
+    </bean> -->
+
+    <!-- <mvc:annotation-driven/>
+    <mvc:default-servlet-handler/> -->
+    <!--    <mvc:interceptors>-->
+    <!--        <mvc:interceptor>-->
+    <!--            <mvc:mapping path="/*"/>-->
+    <!--            <mvc:exclude-mapping path="/LoginPage"/>-->
+    <!--            <bean id="InterceptorLogin" class="MVCTry.InterceptorLogin"/>-->
+    <!--        </mvc:interceptor>-->
+    <!--    </mvc:interceptors>-->
+</beans>