Преглед на файлове

Merge remote-tracking branch 'origin/master'

yangrenwei преди 3 години
родител
ревизия
e20af47dbf

+ 72 - 92
src/main/java/group04/BasicNode.java

@@ -11,8 +11,6 @@ import group04.myBatis.Nodeinfo;
  */
 public class BasicNode implements Iterable<BasicNode>
 {
-
-    public boolean needUpload = true;
     /**
      * <0 : invalidity node
      * =0 : undifineded node
@@ -26,9 +24,8 @@ public class BasicNode implements Iterable<BasicNode>
     
     private BasicNode childLevel = null;
     private BasicNode parentNode = null;
-    
 
-    private static ArrayList<ArrayList<BasicNode>> loadedNodes = new ArrayList<>();
+    private static ArrayList<BasicNode> NeedUpload = new ArrayList<>();
 
     /**
      * create new node
@@ -104,6 +101,17 @@ public class BasicNode implements Iterable<BasicNode>
         return childLevel;
     }
 
+    public void setNeedUpload()
+    {
+        synchronized(NeedUpload)
+        {
+            if(!NeedUpload.contains(this))
+            {
+                NeedUpload.add(this);
+            }
+        }
+    }
+
     /**
      * set Node id,also it can destroy this node by seting id to minus value
      * @param id new id
@@ -122,7 +130,6 @@ public class BasicNode implements Iterable<BasicNode>
                 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)
@@ -160,7 +167,6 @@ public class BasicNode implements Iterable<BasicNode>
             {
                 InitAfterLoad(id);
             }
-            if(!defineded()) addLoadedNode(this);
             this.id = id;
         }
     }
@@ -218,12 +224,8 @@ public class BasicNode implements Iterable<BasicNode>
     {
         synchronized(this)
         {
-            if(needUpload)
-            {
-                Nodeinfo data = getNodeInfo();
-                NodeDao.getCurrentMapper().updateByPrimaryKey(data);
-                needUpload = false;
-            }
+            Nodeinfo data = getNodeInfo();
+            NodeDao.getCurrentMapper().updateByPrimaryKey(data);
         }
     }
 
@@ -233,7 +235,14 @@ public class BasicNode implements Iterable<BasicNode>
      */
     public boolean vaildity()
     {
-        return getId() >= 0;
+        if(getId() >= 0)
+        {
+            for (BasicNode basicNode : NeedUpload) {
+                if(this.equals(basicNode) && basicNode != this) return false;
+            }
+            return true;
+        }
+        return false;
     }
 
     /**
@@ -242,7 +251,7 @@ public class BasicNode implements Iterable<BasicNode>
      */
     public boolean defineded()
     {
-        return getId() > 0;
+        return vaildity() && getId() > 0;
     }
 
     /**
@@ -264,23 +273,24 @@ public class BasicNode implements Iterable<BasicNode>
             if(this.nextNode != null)
             {
                 this.nextNode.pervNode = this.pervNode;
-                this.nextNode.needUpload = true;
+                this.nextNode.setNeedUpload();
+                
             }
             if(this.pervNode != null)
             {
                 this.pervNode.nextNode = this.nextNode;
-                this.pervNode.needUpload = true;
+                this.pervNode.setNeedUpload();
             }
             else
             if(this.parentNode != null)
             {
                 this.parentNode.childLevel = this.nextNode;
-                this.parentNode.needUpload = true;
+                this.parentNode.setNeedUpload();
             }
             this.parentNode = null;
             this.nextNode = null;
             this.pervNode = null;
-            this.needUpload = true;
+            this.setNeedUpload();
         }
     }
     
@@ -311,10 +321,10 @@ public class BasicNode implements Iterable<BasicNode>
                     if(nextNode != null)
                     {
                         nextNode.pervNode = node;
-                        nextNode.needUpload = true;
+                        nextNode.setNeedUpload();
                     }
     
-                    this.needUpload = true;
+                    this.setNeedUpload();
                     return true;
                 }
             }
@@ -349,16 +359,16 @@ public class BasicNode implements Iterable<BasicNode>
                     if(pervNode != null)
                     {
                         pervNode.nextNode = node;
-                        pervNode.needUpload = true;
+                        pervNode.setNeedUpload();
                     }
                     else //remove if parrentNode exiet
                     if(this.parentNode != null)
                     {
                         this.parentNode.childLevel = node;
-                        this.parentNode.needUpload = true;
+                        this.parentNode.setNeedUpload();
                     }
     
-                    this.needUpload = true;
+                    this.setNeedUpload();
                     return true;
                 }
             }
@@ -396,7 +406,7 @@ public class BasicNode implements Iterable<BasicNode>
                     if(node.parentNode != null)
                     {
                         node.parentNode.childLevel = node;
-                        node.parentNode.needUpload = true;
+                        node.parentNode.setNeedUpload();
                     }
                     return true;
                 }
@@ -439,46 +449,46 @@ public class BasicNode implements Iterable<BasicNode>
                     node.nextNode = this.nextNode;
                     node.pervNode = this.pervNode;
                     node.parentNode = this.parentNode;
-                    node.needUpload = true;
+                    node.setNeedUpload();
                     //check near by node update
                     if(node.nextNode != null)
                     {
                         node.nextNode.pervNode = node;
-                        node.nextNode.needUpload = true;
+                        node.nextNode.setNeedUpload();
                     }
                     if(node.pervNode != null)
                     {
                         node.pervNode.nextNode = node;
-                        node.pervNode.needUpload = true;
+                        node.pervNode.setNeedUpload();
                     }
                     else
                     if(node.parentNode != null)
                     {
                         node.parentNode.childLevel = node;
-                        node.parentNode.needUpload = true;
+                        node.parentNode.setNeedUpload();
                     }
     
                     //set this to next
                     this.nextNode = next;
                     this.pervNode = perv;
                     this.parentNode = parent;
-                    this.needUpload = true;
+                    this.setNeedUpload();
                     //check near by node update
                     if(this.nextNode != null)
                     {
                         this.nextNode.pervNode = this;
-                        this.nextNode.needUpload = true;
+                        this.nextNode.setNeedUpload();
                     }
                     if(this.pervNode != null)
                     {
                         this.pervNode.nextNode = this;
-                        this.pervNode.needUpload = true;
+                        this.pervNode.setNeedUpload();
                     }
                     else
                     if(this.parentNode != null)
                     {
                         this.parentNode.childLevel = this;
-                        this.parentNode.needUpload = true;
+                        this.parentNode.setNeedUpload();
                     }
                     return true;
                 }
@@ -586,7 +596,7 @@ public class BasicNode implements Iterable<BasicNode>
                 do
                 {
                     //check 2 node's perv node at same time
-                    if(cache1 == this || cache2 == node)
+                    if(cache1.equals(this) || cache2.equals(node))
                         return true;
                     if(cache1.pervNode != null)
                         cache1 = cache1.pervNode;
@@ -625,7 +635,7 @@ public class BasicNode implements Iterable<BasicNode>
         {
             do
             {
-                if(node == this)
+                if(node.equals(this))
                 {
                     return true;
                 }
@@ -663,91 +673,61 @@ public class BasicNode implements Iterable<BasicNode>
         return result + " }";
     }
 
-
     public void deleteNode() throws IOException
     {
         this.setId(-1l);
     }
 
-
-    private static void addLoadedNode(BasicNode node)
+    /**
+     * 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)
     {
-        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);
+        return levelA.startOfNodeLevel().id == levelB.startOfNodeLevel().id;
     }
 
-
-    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;
-            }
-        }
+    @Override
+    public boolean equals(Object o) {
+        // TODO Auto-generated method stub
+        BasicNode other = (BasicNode)o;
+        if(other != null) return other.id == this.id;
+        else return super.equals(o);
     }
 
     /**
-     * find node from node pool, if target is not exiets, it will return null
-     * @param id target id
-     * @return target
+     * check all loaded node and upload data
+     * @throws IOException no sql mapper
      */
-    public static BasicNode getLoadedNodeById(long id)
+    public static void Commit() throws IOException
     {
-        for (ArrayList<BasicNode> list : loadedNodes)
+        synchronized(NeedUpload)
         {
-            for (BasicNode basicNode : list)
+            for (BasicNode basicNode : NeedUpload)
             {
-                if(basicNode.getId() == id)
-                {
-                    return basicNode;
-                }
+                basicNode.uploadNode();
             }
+            NodeDao.getCurrentMapper().commit();
+            NeedUpload.clear();
         }
-        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
+    public static BasicNode TryGetNotCommitNodeById(long id)
     {
-        for (ArrayList<BasicNode> list : loadedNodes)
+        synchronized(NeedUpload)
         {
-            for (BasicNode basicNode : list)
+            for (BasicNode basicNode : NeedUpload)
             {
-                if(basicNode.needUpload)
+                if(basicNode.getId() == id)
                 {
-                    basicNode.uploadNode();
+                    return basicNode;
                 }
             }
+            return null;
         }
-        NodeDao.getCurrentMapper().commit();
     }
 
     /**

+ 36 - 31
src/main/java/group04/NodeDao.java

@@ -45,51 +45,55 @@ public class NodeDao
         BasicNode result = null;
         if(id > 0)
         {
-            result = BasicNode.getLoadedNodeById(id);
+            daoState = DaoState.Reading;
+            result = BasicNode.TryGetNotCommitNodeById(id);
             if(result == null)
+            try
             {
-                daoState = DaoState.Reading;
-                try
+                ArrayList<BasicNode> tree = new ArrayList<>();
+                Nodeinfo data = getCurrentMapper().selectByPrimaryKey(id);
+                if(data != null)
                 {
-                    Nodeinfo data = getCurrentMapper().selectByPrimaryKey(id);
-                    if(data != null)
+                    while(data.getParentId() != null)
                     {
-                        while(data.getParentId() != null)
+                        Nodeinfo cache = data;
+                        data = getCurrentMapper().selectByPrimaryKey(data.getParentId());
+                        if(data == null)
                         {
-                            Nodeinfo cache = data;
-                            data = getCurrentMapper().selectByPrimaryKey(data.getParentId());
-                            if(data == null)
-                            {
-                                data = cache;
-                                break;
-                            }
+                            data = cache;
+                            break;
                         }
-                        while(data.getPrevId() != null)
+                    }
+                    while(data.getPrevId() != null)
+                    {
+                        Nodeinfo cache = data;
+                        data = getCurrentMapper().selectByPrimaryKey(data.getPrevId());
+                        if(data == null)
                         {
-                            Nodeinfo cache = data;
-                            data = getCurrentMapper().selectByPrimaryKey(data.getPrevId());
-                            if(data == null)
-                            {
-                                data = cache;
-                                break;
-                            }
+                            data = cache;
+                            break;
+                        }
+                    }
+                    loadAllInLevel(data,tree);
+                    for (BasicNode basicNode : tree)
+                    {
+                        if(basicNode != null && basicNode.getId() == id)
+                        {
+                            return basicNode;
                         }
-                        loadAllInLevel(data);
                     }
                 }
-                catch(Exception ex)
-                {
-                    System.out.println(ex.toString());
-                    return null;
-                }
-                result = BasicNode.getLoadedNodeById(id);
-                daoState = DaoState.None;
+            }
+            catch(Exception ex)
+            {
+                System.out.println(ex.toString());
+                return null;
             }
         }
         return result;
     }
 
-    private static BasicNode loadAllInLevel(Nodeinfo nodeinfo) throws IOException
+    private static BasicNode loadAllInLevel(Nodeinfo nodeinfo, ArrayList<BasicNode> tree) throws IOException
     {
         if(nodeinfo != null)
         {
@@ -113,8 +117,9 @@ public class NodeDao
                     {
                         nodes.get(i).insertNext(nodes.get(i + 1));
                     }
-                    nodes.get(i).setChildLevel(loadAllInLevel(infos.get(i)));
+                    nodes.get(i).setChildLevel(loadAllInLevel(infos.get(i),tree));
                 }
+                tree.addAll(nodes);
                 return nodes.get(0);
             } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException
                     | NoSuchMethodException | SecurityException | ClassNotFoundException e) {

+ 1 - 1
src/main/java/group04/nodeOptConsol.java

@@ -218,7 +218,7 @@ public class nodeOptConsol {
                 }
                 break;
                 case "ex":
-                BasicNode.checkAndUploadAll();
+                BasicNode.Commit();
                 return;
             }
         }

+ 24 - 28
src/main/resources/DataBase.sql

@@ -1,12 +1,27 @@
+drop database if exists ShoppingWebsite;
 create database if not exists ShoppingWebsite;
 use ShoppingWebsite;
 
 
 
+
+/*  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'
+);
+
 /*  node stuctor
     userAccount
-    +   user_cart
-    +   user_collect
+    +   cart
+        +   user_cart[]
+    +   collect
+        +   goods[]
 */
 create table if not exists userAccount
 (
@@ -17,26 +32,19 @@ create table if not exists userAccount
     primary key(email,userId)
 );
 
+/*goods*/
 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
+    count int not null,
 );
 
-
 /*  node stuctor
     store
-    +   goods
-        +   selectionGroup
-            +   selection
+    +   goods[]
+        +   selectionGroup[]
+            +   selection[]
+        +   comment[]
 */
 create table if not exists store
 (
@@ -54,7 +62,7 @@ create table if not exists goods
     star int
 );
 
-create table if not exists selectionGroup
+create table if not exists selection_group
 (
     selection_group_id bigint not null primary key,
     name varchar(50) not null
@@ -66,15 +74,3 @@ create table if not exists selection
     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'
-);

+ 44 - 4
src/main/resources/generatorConfig.xml

@@ -11,7 +11,7 @@
         </commentGenerator>
         <jdbcConnection
                 driverClass="com.mysql.jdbc.Driver"
-                connectionURL="jdbc:mysql://localhost:3306/dsnodetree"
+                connectionURL="jdbc:mysql://localhost:3306/ShoppingWebsite"
                 userId="root"
                 password="123456"
         />
@@ -19,7 +19,7 @@
             <property name="forceBigDecimals" value="false"/>
         </javaTypeResolver>
 
-        <javaModelGenerator targetPackage="group04.myBatis" targetProject="src/main/java">
+        <javaModelGenerator targetPackage="WebsiteES.myBatis" targetProject="src/main/java">
             <property name="enableSubPackages" value="true"/>
             <property name="trimStrings" value="false"/>
         </javaModelGenerator>
@@ -28,12 +28,52 @@
             <property name="enableSubPackages" value="true"/>
         </sqlMapGenerator>
 
-        <javaClientGenerator targetPackage="group04.myBatis" targetProject="src/main/java" type="XMLMAPPER">
+        <javaClientGenerator targetPackage="WebsiteES.myBatis" targetProject="src/main/java" type="XMLMAPPER">
             <property name="enableSubPackages" value="true"/>
         </javaClientGenerator>
 
         <table
-                tableName="nodeinfo"
+                tableName="userAccount"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="user_cart"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="store"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="goods"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="selectionGroup"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="selection"
         enableCountByExample="false"
         enableDeleteByExample="false"
         enableSelectByExample="false"

+ 37 - 37
src/main/resources/myBatisMap/NodeinfoMapper.xml

@@ -1,26 +1,26 @@
-<?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" >
+<?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="WebsiteES.myBatis.NodeinfoMapper">
+  <resultMap id="BaseResultMap" type="WebsiteES.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" />
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="prev_id" jdbcType="BIGINT" property="prevId" />
+    <result column="next_id" jdbcType="BIGINT" property="nextId" />
+    <result column="parent_id" jdbcType="BIGINT" property="parentId" />
+    <result column="child_id" jdbcType="BIGINT" property="childId" />
+    <result column="obj_type" jdbcType="VARCHAR" property="objType" />
   </resultMap>
-  <sql id="Base_Column_List" >
+  <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" >
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -30,7 +30,7 @@
     from nodeinfo
     where id = #{id,jdbcType=BIGINT}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -38,7 +38,7 @@
     delete from nodeinfo
     where id = #{id,jdbcType=BIGINT}
   </delete>
-  <insert id="insert" parameterType="group04.myBatis.Nodeinfo" >
+  <insert id="insert" parameterType="WebsiteES.myBatis.Nodeinfo">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -50,79 +50,79 @@
       #{parentId,jdbcType=BIGINT}, #{childId,jdbcType=BIGINT}, #{objType,jdbcType=VARCHAR}
       )
   </insert>
-  <insert id="insertSelective" parameterType="group04.myBatis.Nodeinfo" >
+  <insert id="insertSelective" parameterType="WebsiteES.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" >
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
         id,
       </if>
-      <if test="prevId != null" >
+      <if test="prevId != null">
         prev_id,
       </if>
-      <if test="nextId != null" >
+      <if test="nextId != null">
         next_id,
       </if>
-      <if test="parentId != null" >
+      <if test="parentId != null">
         parent_id,
       </if>
-      <if test="childId != null" >
+      <if test="childId != null">
         child_id,
       </if>
-      <if test="objType != null" >
+      <if test="objType != null">
         obj_type,
       </if>
     </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides="," >
-      <if test="id != null" >
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
-      <if test="prevId != null" >
+      <if test="prevId != null">
         #{prevId,jdbcType=BIGINT},
       </if>
-      <if test="nextId != null" >
+      <if test="nextId != null">
         #{nextId,jdbcType=BIGINT},
       </if>
-      <if test="parentId != null" >
+      <if test="parentId != null">
         #{parentId,jdbcType=BIGINT},
       </if>
-      <if test="childId != null" >
+      <if test="childId != null">
         #{childId,jdbcType=BIGINT},
       </if>
-      <if test="objType != null" >
+      <if test="objType != null">
         #{objType,jdbcType=VARCHAR},
       </if>
     </trim>
   </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="group04.myBatis.Nodeinfo" >
+  <update id="updateByPrimaryKeySelective" parameterType="WebsiteES.myBatis.Nodeinfo">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     update nodeinfo
-    <set >
-      <if test="prevId != null" >
+    <set>
+      <if test="prevId != null">
         prev_id = #{prevId,jdbcType=BIGINT},
       </if>
-      <if test="nextId != null" >
+      <if test="nextId != null">
         next_id = #{nextId,jdbcType=BIGINT},
       </if>
-      <if test="parentId != null" >
+      <if test="parentId != null">
         parent_id = #{parentId,jdbcType=BIGINT},
       </if>
-      <if test="childId != null" >
+      <if test="childId != null">
         child_id = #{childId,jdbcType=BIGINT},
       </if>
-      <if test="objType != null" >
+      <if test="objType != null">
         obj_type = #{objType,jdbcType=VARCHAR},
       </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
-  <update id="updateByPrimaryKey" parameterType="group04.myBatis.Nodeinfo" >
+  <update id="updateByPrimaryKey" parameterType="WebsiteES.myBatis.Nodeinfo">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.

+ 24 - 28
target/classes/DataBase.sql

@@ -1,12 +1,27 @@
+drop database if exists ShoppingWebsite;
 create database if not exists ShoppingWebsite;
 use ShoppingWebsite;
 
 
 
+
+/*  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'
+);
+
 /*  node stuctor
     userAccount
-    +   user_cart
-    +   user_collect
+    +   cart
+        +   user_cart[]
+    +   collect
+        +   goods[]
 */
 create table if not exists userAccount
 (
@@ -17,26 +32,19 @@ create table if not exists userAccount
     primary key(email,userId)
 );
 
+/*goods*/
 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
+    count int not null,
 );
 
-
 /*  node stuctor
     store
-    +   goods
-        +   selectionGroup
-            +   selection
+    +   goods[]
+        +   selectionGroup[]
+            +   selection[]
+        +   comment[]
 */
 create table if not exists store
 (
@@ -54,7 +62,7 @@ create table if not exists goods
     star int
 );
 
-create table if not exists selectionGroup
+create table if not exists selection_group
 (
     selection_group_id bigint not null primary key,
     name varchar(50) not null
@@ -66,15 +74,3 @@ create table if not exists selection
     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'
-);

+ 44 - 4
target/classes/generatorConfig.xml

@@ -11,7 +11,7 @@
         </commentGenerator>
         <jdbcConnection
                 driverClass="com.mysql.jdbc.Driver"
-                connectionURL="jdbc:mysql://localhost:3306/dsnodetree"
+                connectionURL="jdbc:mysql://localhost:3306/ShoppingWebsite"
                 userId="root"
                 password="123456"
         />
@@ -19,7 +19,7 @@
             <property name="forceBigDecimals" value="false"/>
         </javaTypeResolver>
 
-        <javaModelGenerator targetPackage="group04.myBatis" targetProject="src/main/java">
+        <javaModelGenerator targetPackage="WebsiteES.myBatis" targetProject="src/main/java">
             <property name="enableSubPackages" value="true"/>
             <property name="trimStrings" value="false"/>
         </javaModelGenerator>
@@ -28,12 +28,52 @@
             <property name="enableSubPackages" value="true"/>
         </sqlMapGenerator>
 
-        <javaClientGenerator targetPackage="group04.myBatis" targetProject="src/main/java" type="XMLMAPPER">
+        <javaClientGenerator targetPackage="WebsiteES.myBatis" targetProject="src/main/java" type="XMLMAPPER">
             <property name="enableSubPackages" value="true"/>
         </javaClientGenerator>
 
         <table
-                tableName="nodeinfo"
+                tableName="userAccount"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="user_cart"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="store"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="goods"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="selectionGroup"
+        enableCountByExample="false"
+        enableDeleteByExample="false"
+        enableSelectByExample="false"
+        enableUpdateByExample="false"
+        />
+
+        <table
+                tableName="selection"
         enableCountByExample="false"
         enableDeleteByExample="false"
         enableSelectByExample="false"

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/nodeOptConsol.class


+ 37 - 37
target/classes/myBatisMap/NodeinfoMapper.xml

@@ -1,26 +1,26 @@
-<?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" >
+<?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="WebsiteES.myBatis.NodeinfoMapper">
+  <resultMap id="BaseResultMap" type="WebsiteES.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" />
+    <id column="id" jdbcType="BIGINT" property="id" />
+    <result column="prev_id" jdbcType="BIGINT" property="prevId" />
+    <result column="next_id" jdbcType="BIGINT" property="nextId" />
+    <result column="parent_id" jdbcType="BIGINT" property="parentId" />
+    <result column="child_id" jdbcType="BIGINT" property="childId" />
+    <result column="obj_type" jdbcType="VARCHAR" property="objType" />
   </resultMap>
-  <sql id="Base_Column_List" >
+  <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" >
+  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -30,7 +30,7 @@
     from nodeinfo
     where id = #{id,jdbcType=BIGINT}
   </select>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
+  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -38,7 +38,7 @@
     delete from nodeinfo
     where id = #{id,jdbcType=BIGINT}
   </delete>
-  <insert id="insert" parameterType="group04.myBatis.Nodeinfo" >
+  <insert id="insert" parameterType="WebsiteES.myBatis.Nodeinfo">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
@@ -50,79 +50,79 @@
       #{parentId,jdbcType=BIGINT}, #{childId,jdbcType=BIGINT}, #{objType,jdbcType=VARCHAR}
       )
   </insert>
-  <insert id="insertSelective" parameterType="group04.myBatis.Nodeinfo" >
+  <insert id="insertSelective" parameterType="WebsiteES.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" >
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="id != null">
         id,
       </if>
-      <if test="prevId != null" >
+      <if test="prevId != null">
         prev_id,
       </if>
-      <if test="nextId != null" >
+      <if test="nextId != null">
         next_id,
       </if>
-      <if test="parentId != null" >
+      <if test="parentId != null">
         parent_id,
       </if>
-      <if test="childId != null" >
+      <if test="childId != null">
         child_id,
       </if>
-      <if test="objType != null" >
+      <if test="objType != null">
         obj_type,
       </if>
     </trim>
-    <trim prefix="values (" suffix=")" suffixOverrides="," >
-      <if test="id != null" >
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="id != null">
         #{id,jdbcType=BIGINT},
       </if>
-      <if test="prevId != null" >
+      <if test="prevId != null">
         #{prevId,jdbcType=BIGINT},
       </if>
-      <if test="nextId != null" >
+      <if test="nextId != null">
         #{nextId,jdbcType=BIGINT},
       </if>
-      <if test="parentId != null" >
+      <if test="parentId != null">
         #{parentId,jdbcType=BIGINT},
       </if>
-      <if test="childId != null" >
+      <if test="childId != null">
         #{childId,jdbcType=BIGINT},
       </if>
-      <if test="objType != null" >
+      <if test="objType != null">
         #{objType,jdbcType=VARCHAR},
       </if>
     </trim>
   </insert>
-  <update id="updateByPrimaryKeySelective" parameterType="group04.myBatis.Nodeinfo" >
+  <update id="updateByPrimaryKeySelective" parameterType="WebsiteES.myBatis.Nodeinfo">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.
     -->
     update nodeinfo
-    <set >
-      <if test="prevId != null" >
+    <set>
+      <if test="prevId != null">
         prev_id = #{prevId,jdbcType=BIGINT},
       </if>
-      <if test="nextId != null" >
+      <if test="nextId != null">
         next_id = #{nextId,jdbcType=BIGINT},
       </if>
-      <if test="parentId != null" >
+      <if test="parentId != null">
         parent_id = #{parentId,jdbcType=BIGINT},
       </if>
-      <if test="childId != null" >
+      <if test="childId != null">
         child_id = #{childId,jdbcType=BIGINT},
       </if>
-      <if test="objType != null" >
+      <if test="objType != null">
         obj_type = #{objType,jdbcType=VARCHAR},
       </if>
     </set>
     where id = #{id,jdbcType=BIGINT}
   </update>
-  <update id="updateByPrimaryKey" parameterType="group04.myBatis.Nodeinfo" >
+  <update id="updateByPrimaryKey" parameterType="WebsiteES.myBatis.Nodeinfo">
     <!--
       WARNING - @mbggenerated
       This element is automatically generated by MyBatis Generator, do not modify.