Procházet zdrojové kódy

更新mysql的xml映射文件

周浩 před 9 roky
rodič
revize
000cd504c8

+ 159 - 63
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/basic/BasicMapper.xml

@@ -4,92 +4,188 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="BasicMapper">
     <!--通用查询条件-->
-    <sql id="selectCondition">
-            <!--动态生成查询条件-->
-            <foreach item="item" index="index" collection="$fields">
-                <if test="#this['term.'+item]!=null">
-                    AND ${$tableName}.${item}=#{term.${item}}
-                </if>
-                <if test="#this['term.'+item+'$NOT']!=null">
-                    AND ${$tableName}.${item}!=#{term.${item+'$NOT'}}
-                </if>
-                <if test="#this['term.'+item+'$LIKE']!=null">
-                    AND INSTR(${$tableName}.${item},#{term.${item+'$LIKE'}})>0
-                </if>
-                <if test="#this['term.'+item+'$NOTLIKE']!=null">
-                    AND INSTR(${$tableName}.${item},#{term.${item+'$NOTLIKE'}})&lt;=0
-                </if>
-                <if test="#this['term.'+item+'$START']!=null">
-                    AND ${$tableName}.${item} LIKE CONCAT(#{term.${item+'$START'}},'%')
-                </if>
-                <if test="#this['term.'+item+'$END']!=null">
-                    AND ${$tableName}.${item} LIKE CONCAT('%',#{term.${item+'$END'})
-                </if>
-                <if test="#this['term.'+item+'$IN']!=null">
-                    AND ${$tableName}.${item} IN
-                    <foreach item="it" index="i" collection="#this['term.'+item+'$IN']" open="(" separator="," close=")">
-                        #{it}
-                    </foreach>
-                </if>
-                <if test="#this['term.'+item+'$NOTIN']!=null">
-                    AND ${$tableName}.${item} NOT IN
-                    <foreach item="it" index="i" collection="#this['term.'+item+'$NOTIN']" open="(" separator="," close=")">
-                        #{it}
-                    </foreach>
-                </if>
-                <if test="#this['term.'+item+'$ISNULL']!=null">
-                    AND ${$tableName}.${item} IS NULL
-                </if>
-                <if test="#this['term.'+item+'$NOTNULL']!=null">
-                    AND ${$tableName}.${item} IS NOT NULL
-                </if>
-                <if test="#this['term.'+item+'$GT']!=null">
-                    AND ${$tableName}.${item} &gt;=#{term.${item+'$GT'}}
-                </if>
-                <if test="#this['term.'+item+'$LT']!=null">
-                    AND ${$tableName}.${item} &lt;=#{term.${item+'$LT'}}
-                </if>
-            </foreach>
+    <sql id="buildWhere">
+        <!--动态生成查询条件-->
+        <foreach item="item" index="index" collection="$fields">
+            <if test="#this['term.'+item]!=null">
+                AND `${$tableName}`.`${item}`=#{term.${item}}
+            </if>
+            <if test="#this['term.'+item+'$NOT']!=null">
+                AND `${$tableName}`.`${item}`!=#{term.${item+'$NOT'}}
+            </if>
+            <if test="#this['term.'+item+'$LIKE']!=null">
+                AND INSTR(`${$tableName}`.`${item}`,#{term.${item+'$LIKE'}})>0
+            </if>
+            <if test="#this['term.'+item+'$NOTLIKE']!=null">
+                AND INSTR(`${$tableName}`.`${item}`,#{term.${item+'$NOTLIKE'}})&lt;=0
+            </if>
+            <if test="#this['term.'+item+'$START']!=null">
+                AND `${$tableName}`.`${item}` LIKE CONCAT(#{term.${item+'$START'}},'%')
+            </if>
+            <if test="#this['term.'+item+'$END']!=null">
+                AND `${$tableName}`.`${item}` LIKE CONCAT('%',#{term.${item+'$END'})
+            </if>
+            <if test="#this['term.'+item+'$IN']!=null">
+                AND `${$tableName}`.`${item}` IN
+                <foreach item="it" index="i" collection="#this['term.'+item+'$IN']" open="(" separator="," close=")">
+                    #{it}
+                </foreach>
+            </if>
+            <if test="#this['term.'+item+'$NOTIN']!=null">
+                AND `${$tableName}`.`${item}` NOT IN
+                <foreach item="it" index="i" collection="#this['term.'+item+'$NOTIN']" open="(" separator="," close=")">
+                    #{it}
+                </foreach>
+            </if>
+            <if test="#this['term.'+item+'$ISNULL']!=null">
+                AND `${$tableName}`.`${item}` IS NULL
+            </if>
+            <if test="#this['term.'+item+'$NOTNULL']!=null">
+                AND `${$tableName}`.`${item}` IS NOT NULL
+            </if>
+            <if test="#this['term.'+item+'$GT']!=null">
+                AND `${$tableName}`.`${item}` &gt;=#{term.${item+'$GT'}}
+            </if>
+            <if test="#this['term.'+item+'$LT']!=null">
+                AND `${$tableName}`.`${item}` &lt;=#{term.${item+'$LT'}}
+            </if>
+        </foreach>
         <!--动态生成查询条件结束-->
     </sql>
     <!--生成查询字段-->
-    <sql id="selectField">
+    <sql id="buildSelectField">
+        <choose>
+            <!--指定查询的字段-->
+            <when test="includes!=null and includes.size()>0">
+                <foreach item="item" index="index" collection="includes" open="" separator="," close="">
+                    <if test="item in $fields">
+                        ${$tableName}.${item} as `{item}`
+                    </if>
+                </foreach>
+            </when>
+            <!--指定不查询的字段-->
+            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
+                <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
+                    <if test="!(item in excludes)">
+                        ${$tableName}.${item} as `${item}`
+                    </if>
+                </foreach>
+            </when>
+            <otherwise>*</otherwise>
+        </choose>
+    </sql>
+
+    <!--生成修改字段-->
+    <sql id="buildUpdateField">
+        <set>
             <choose>
-                <!--指定查询的字段 -->
-                <when test="#this['includes']!=null and #this['includes'].size()>0">
-                    <foreach item="item" index="index" collection="#this['includes']" open="" separator="," close="">
+                <!--指定要修改的字段-->
+                <when test="includes!=null and includes.size()>0">
+                    <foreach item="item" index="index" collection="includes" open="" separator="," close="">
                         <if test="item in $fields">
-                            ${$tableName}.${item} as `${item}`
+                            `${item}`=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
                         </if>
                     </foreach>
                 </when>
-                <!--指定不查询的字段-->
-                <when test="(#this['includes']==null or #this['includes'].size()==0) and #this['excludes']!=null and #this['excludes'].size()>0">
+                <!--指定不修改的字段-->
+                <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
                     <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
-                        <if test="!(item in #this['excludes'])">
-                            ${$tableName}.${item} as `${item}`
+                        <if test="!(item in excludes)">
+                            `${item}`= #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
                         </if>
                     </foreach>
                 </when>
-                <otherwise>*</otherwise>
+                <!--修改所有-->
+                <otherwise>
+                    <foreach item="item" index="index" collection="$fields" open=" " separator="," close="">
+                        <if test="data[item] != null">
+                            `${item}`=#{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
+                        </if>
+                    </foreach>
+                </otherwise>
             </choose>
+        </set>
+    </sql>
+
+    <!--生成插入字段-->
+    <sql id="buildInsertField">
+        <choose>
+            <when test="includes!=null and includes.size()>0">
+                <foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
+                    <if test="item in $fields">`${item}`</if>
+                </foreach>
+            </when>
+            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
+                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
+                    <if test="!(item in excludes)">`${item}`</if>
+                </foreach>
+            </when>
+            <otherwise>
+                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">`${item}`</foreach>
+            </otherwise>
+        </choose>
+    </sql>
+
+    <!--生成插入值-->
+    <sql id="buildInsertValues">
+        <choose>
+            <when test="includes!=null and includes.size()>0">
+                <foreach item="item" index="index" collection="includes" open="(" separator="," close=")">
+                    <if test="item in $fields">
+                        #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
+                    </if>
+                </foreach>
+            </when>
+            <when test="(includes==null or includes.size()==0) and excludes!=null and excludes.size()>0">
+                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
+                    <if test="!(item in excludes)">
+                        #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
+                    </if>
+                </foreach>
+            </when>
+            <otherwise>
+                <foreach item="item" index="index" collection="$fields" open="(" separator="," close=")">
+                    #{data.${item},jdbcType=${$fieldsInfo[item]['jdbcType']}}
+                </foreach>
+            </otherwise>
+        </choose>
     </sql>
 
     <!--生成查询sql-->
     <sql id="buildSelectSql">
-        SELECT
-        <include refid="BasicMapper.selectField"/>
-        FROM ${$tableName}
+        select
+        <include refid="BasicMapper.buildSelectField"/>
+        from ${$tableName}
+        <where>
+            <include refid="BasicMapper.buildWhere"/>
+        </where>
+    </sql>
+
+    <!--生成InsertSql-->
+    <sql id="buildInsertSql">
+        insert into ${$tableName}
+        <include refid="BasicMapper.buildInsertField"/>
+        values
+        <include refid="BasicMapper.buildInsertValues"/>
+    </sql>
+
+    <!--生成UpdateSql-->
+    <sql id="buildUpdateSql">
+        update ${$tableName}
+        <include refid="BasicMapper.buildUpdateField"/>
         <where>
-            <include refid="BasicMapper.selectCondition"/>
+            <include refid="BasicMapper.buildWhere"/>
+            <if test="term.size()==0">
+                u_id=#{data.u_id}
+            </if>
         </where>
     </sql>
 
     <!--生成查询数量sql-->
-    <sql id="totalSql">
-        SELECT count(0) AS total FROM ${$tableName}
+    <sql id="buildTotalSql">
+        select count(0) as "total" from ${$tableName}
         <where>
-            <include refid="BasicMapper.selectCondition"/>
+            <include refid="BasicMapper.buildWhere"/>
         </where>
     </sql>
 </mapper>

+ 28 - 35
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/config/ConfigMapper.xml

@@ -4,58 +4,51 @@
         "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
 
 <mapper namespace="org.hsweb.web.dao.config.ConfigMapper">
-    <resultMap id="ConfigResultMap" type="Config" >
-        <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR" />
-        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR" />
-        <result property="content" column="content" javaType="String" jdbcType="VARCHAR" />
-        <result property="create_date" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP" />
-        <result property="update_date" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP" />
+    <resultMap id="ConfigResultMap" type="Config">
+        <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
+        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
+        <result property="content" column="content" javaType="String" jdbcType="VARCHAR"/>
+        <result property="create_date" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
+        <result property="update_date" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
     </resultMap>
+
     <!--字段信息配置-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','remark':'string','content':'string'
-                    ,'create_date':'date','update_date':'date'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'remark':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'content':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'create_date':#{'jdbcType':'VARCHAR','javaType':'date'}
+                    ,'update_date':#{'jdbcType':'VARCHAR','javaType':'date'}
+                    }"/>
+
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
     <!--表名-->
     <sql id="tableName">
-        <bind name="$tableName" value="'S_CONFIG'"/>
+        <bind name="$tableName" value="'s_config'"/>
     </sql>
 
-    <insert id="insert" parameterType="Config" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_CONFIG
-        (u_id,remark,content,create_date,update_date)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{create_date,jdbcType=TIMESTAMP},#{update_date,jdbcType=TIMESTAMP})
+    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="Config" >
-        DELETE FROM S_CONFIG WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_config where u_id=#{term.primaryKey}
     </delete>
 
-    <update id="update" parameterType="Config" >
-        UPDATE S_CONFIG
-        <set>
-            <if test="remark != null">
-                remark=#{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="content != null">
-                content=#{content,jdbcType=VARCHAR},
-            </if>
-            <if test="create_date != null">
-                create_date=#{create_date,jdbcType=TIMESTAMP},
-            </if>
-            <if test="update_date != null">
-                update_date=#{update_date,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByPk" parameterType="string" resultMap="ConfigResultMap">
-        SELECT * FROM S_CONFIG WHERE u_id=#{u_id}
+        select * from s_config where u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ConfigResultMap">

+ 60 - 37
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/form/FormMapper.xml

@@ -6,12 +6,13 @@
 <mapper namespace="org.hsweb.web.dao.form.FormMapper">
     <resultMap id="FormResultMap" type="Form">
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
         <result property="html" column="html" javaType="String" jdbcType="VARCHAR"/>
-        <result property="config" column="config" javaType="String" jdbcType="VARCHAR"/>
         <result property="meta" column="meta" javaType="String" jdbcType="VARCHAR"/>
+        <result property="config" column="config" javaType="String" jdbcType="VARCHAR"/>
         <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
+        <result property="version" column="version" javaType="int" jdbcType="INTEGER"/>
+        <result property="using" column="using" javaType="boolean" jdbcType="INTEGER"/>
         <result property="create_date" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
         <result property="update_date" column="update_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
     </resultMap>
@@ -19,54 +20,76 @@
     <!--字段信息绑定-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','name':'string','html':'string','meta':'string'
-                        ,'config':'string','remark':'string','create_date':'string'
-                       ,'update_date':'string'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'html':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'meta':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'config':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'remark':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'version':#{'jdbcType':'INTEGER','javaType':'number'}
+                    ,'using':#{'jdbcType':'INTEGER','javaType':'boolean'}
+                    ,'create_date':#{'jdbcType':'VARCHAR','javaType':'date'}
+                    ,'update_date':#{'jdbcType':'VARCHAR','javaType':'date'}
+                    }"/>
+
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
+
     <!--表名-->
     <sql id="tableName">
-        <bind name="$tableName" value="'S_FORM'"/>
+        <bind name="$tableName" value="'s_form'"/>
     </sql>
 
-    <insert id="insert" parameterType="Form" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_FORM
-        (u_id,name,html,meta,config,remark,create_date,update_date)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{html,jdbcType=VARCHAR},#{meta,jdbcType=VARCHAR},#{config,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{create_date,jdbcType=TIMESTAMP},#{update_date,jdbcType=TIMESTAMP})
+    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="Form">
-        DELETE FROM S_FORM WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_form where u_id=#{term.primaryKey}
     </delete>
 
-    <update id="update" parameterType="Form">
-        UPDATE S_FORM
-        <set>
-            <if test="name != null">
-                name=#{name,jdbcType=VARCHAR},
-            </if>
-            <if test="html != null">
-                html=#{html,jdbcType=VARCHAR},
-            </if>
-            <if test="meta != null">
-                meta=#{meta,jdbcType=VARCHAR},
-            </if>
-            <if test="config != null">
-                config=#{config,jdbcType=VARCHAR},
-            </if>
-            <if test="remark != null">
-                remark=#{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="update_date != null">
-                update_date=#{update_date,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByPk" parameterType="string" resultMap="FormResultMap">
-        SELECT * FROM S_FORM WHERE u_id=#{u_id}
+        select * from s_form WHERE u_id=#{u_id}
+    </select>
+
+    <select id="selectUsing" parameterType="string" resultMap="FormResultMap">
+        select * from s_form WHERE `using`=1 and `name`=#{name}
+    </select>
+
+    <select id="selectLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">
+        <include refid="fieldConfig"/><!--定义字段配置-->
+        <bind name="$tableName" value="'t2'"/><!--定义表名-->
+        select
+        <include refid="BasicMapper.buildSelectField"/> <!--动态生成要查询的字段-->
+        from (
+        select s_form.name,max(s_form.version) as version from s_form s_form
+        <include refid="tableName"/>
+        <where>
+            <include refid="BasicMapper.buildWhere"/> <!--动态查询条件-->
+        </where>
+        group by name ) t1
+        left join s_form t2 on t1.name=t2.name and t1.version =t2.version
+    </select>
+
+    <select id="countLatestList" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        select count(0) as total from (
+        select s_form.name,max(s_form.version) as version from s_form s_form
+        <where>
+            <include refid="BasicMapper.buildWhere"/>
+        </where>
+        group by name) t1
+        left join s_form t2 on t1.name=t2.name and t1.version =t2.version
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="FormResultMap">

+ 73 - 0
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/history/HistoryMapper.xml

@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://www.mybatis.org/dtd/mybatis-3-mapper.dtd">
+
+<mapper namespace="org.hsweb.web.dao.history.HistoryMapper">
+    <resultMap id="HistoryResultMap" type="History">
+        <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
+        <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
+        <result property="describe" column="describe" javaType="String" jdbcType="VARCHAR"/>
+        <result property="primary_key_name" column="primary_key_name" javaType="String" jdbcType="VARCHAR"/>
+        <result property="primary_key_value" column="primary_key_value" javaType="String" jdbcType="VARCHAR"/>
+        <result property="change_before" column="change_before" javaType="String" jdbcType="VARCHAR"/>
+        <result property="change_after" column="change_after" javaType="String" jdbcType="INTEGER"/>
+        <result property="creator_id" column="creator_id" javaType="String" jdbcType="VARCHAR"/>
+        <result property="create_date" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <!--字段信息绑定-->
+    <sql id="fieldConfig">
+        <bind name="$fieldsInfo"
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'type':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'describe':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'primary_key_name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'primary_key_value':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'change_before':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'change_after':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'creator_id':#{'jdbcType':'VARCHAR','javaType':'boolean'}
+                    ,'create_date':#{'jdbcType':'VARCHAR','javaType':'date'}
+                    }"/>
+
+        <bind name="$fields" value="$fieldsInfo.keySet()"/>
+    </sql>
+
+    <!--表名-->
+    <sql id="tableName">
+        <bind name="$tableName" value="'s_history'"/>
+    </sql>
+
+    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
+    </insert>
+
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_history where u_id=#{term.primaryKey}
+    </delete>
+
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
+    </update>
+
+    <select id="selectByPk" parameterType="string" resultMap="HistoryResultMap">
+        select * from s_history WHERE u_id=#{u_id}
+    </select>
+
+    <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="HistoryResultMap">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildSelectSql"/>
+    </select>
+
+    <select id="total" parameterType="org.hsweb.web.bean.common.QueryParam" resultType="int">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildTotalSql"/>
+    </select>
+</mapper>

+ 22 - 40
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/module/ModuleMapper.xml

@@ -6,7 +6,6 @@
 <mapper namespace="org.hsweb.web.dao.module.ModuleMapper">
     <resultMap id="ModuleResultMap" type="Module">
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
         <result property="uri" column="uri" javaType="String" jdbcType="VARCHAR"/>
         <result property="icon" column="icon" javaType="String" jdbcType="VARCHAR"/>
@@ -20,7 +19,17 @@
     <!--字段信息绑定-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','name':'string','uri':'string','icon':'string','p_id':'string','sort_index':'number','m_option':'string','remark':'string','type':'string','status':'number'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'uri':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'icon':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'p_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'remark':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'status':#{'jdbcType':'INTEGER','javaType':'number'}
+                    ,'m_option':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'sort_index':#{'jdbcType':'INTEGER','javaType':'number'}
+                    }"/>
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
     <!--表名-->
@@ -28,51 +37,24 @@
         <bind name="$tableName" value="'S_MODULES'"/>
     </sql>
 
-    <insert id="insert" parameterType="Module" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_MODULES
-        (u_id,name,uri,icon,p_id,remark,status,m_option,sort_index)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{uri,jdbcType=VARCHAR},#{icon,jdbcType=VARCHAR},#{p_id,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{status,jdbcType=INTEGER},#{m_option,jdbcType=VARCHAR},#{sort_index,jdbcType=INTEGER})
+    <insert id="insert" parameterType="org.hsweb.web.bean.common.InsertParam" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="Module">
-        DELETE FROM S_MODULES WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_modules where u_id=#{term.primaryKey}
     </delete>
 
-    <update id="update" parameterType="Module">
-        UPDATE S_MODULES
-        <set>
-            <if test="u_id != null">
-                u_id=#{u_id,jdbcType=VARCHAR},
-            </if>
-            <if test="name != null">
-                name=#{name,jdbcType=VARCHAR},
-            </if>
-            <if test="uri != null">
-                uri=#{uri,jdbcType=VARCHAR},
-            </if>
-            <if test="icon != null">
-                icon=#{icon,jdbcType=VARCHAR},
-            </if>
-            <if test="p_id != null">
-                p_id=#{p_id,jdbcType=VARCHAR},
-            </if>
-            <if test="remark != null">
-                remark=#{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="status != null">
-                status=#{status,jdbcType=INTEGER},
-            </if>
-            <if test="m_option != null">
-                m_option=#{m_option,jdbcType=VARCHAR},
-            </if>
-            sort_index=#{sort_index,jdbcType=INTEGER}
-        </set>
-        WHERE u_id=#{old_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByPk" parameterType="string" resultMap="ModuleResultMap">
-        SELECT * FROM S_MODULES WHERE u_id=#{u_id}
+        select * from s_modules WHERE u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ModuleResultMap">

+ 22 - 38
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/resource/ResourcesMapper.xml

@@ -6,69 +6,53 @@
 <mapper namespace="org.hsweb.web.dao.resource.ResourcesMapper">
     <resultMap id="ResourcesResultMap" type="Resources" >
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR" />
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR" />
         <result property="path" column="path" javaType="String" jdbcType="VARCHAR" />
-        <result property="create_date" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP" />
         <result property="creator_id" column="creator_id" javaType="String" jdbcType="VARCHAR" />
         <result property="md5" column="md5" javaType="String" jdbcType="VARCHAR" />
         <result property="type" column="type" javaType="String" jdbcType="VARCHAR" />
         <result property="status" column="status" javaType="int" jdbcType="INTEGER" />
+        <result property="create_date" column="create_date" javaType="java.util.Date" jdbcType="TIMESTAMP" />
     </resultMap>
 
     <!--字段信息绑定-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','name':'string','path':'string','create_date':'date'
-                    ,'creator_id':'string','md5':'string','type':'string','status':'number'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'path':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'creator_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'md5':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'type':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'status':#{'jdbcType':'INTEGER','javaType':'number'}
+                    ,'create_date':#{'jdbcType':'TIMESTAMP','javaType':'date'}
+                    }"/>
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
     <!--表名-->
     <sql id="tableName">
-        <bind name="$tableName" value="'S_RESOURCES'"/>
+        <bind name="$tableName" value="'s_resources'"/>
     </sql>
 
-    <insert id="insert" parameterType="Resources" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_RESOURCES
-        (u_id,name,path,create_date,creator_id,md5,type,status)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{path,jdbcType=VARCHAR},#{create_date,jdbcType=TIMESTAMP},#{creator_id,jdbcType=VARCHAR},#{md5,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{status,jdbcType=INTEGER})
+    <insert id="insert" parameterType="Resources" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
     <delete id="delete" parameterType="Resources" >
-        DELETE FROM S_RESOURCES WHERE u_id=#{u_id}
+        delete from s_resources where u_id=#{term.primaryKey}
     </delete>
 
-    <update id="update" parameterType="Resources" >
-        UPDATE S_RESOURCES
-        <set>
-            <if test="name != null">
-                name=#{name,jdbcType=VARCHAR},
-            </if>
-            <if test="path != null">
-                path=#{path,jdbcType=VARCHAR},
-            </if>
-            <if test="create_date != null">
-                create_date=#{create_date,jdbcType=TIMESTAMP},
-            </if>
-            <if test="creator_id != null">
-                creator_id=#{creator_id,jdbcType=VARCHAR},
-            </if>
-            <if test="md5 != null">
-                md5=#{md5,jdbcType=VARCHAR},
-            </if>
-            <if test="type != null">
-                type=#{type,jdbcType=VARCHAR},
-            </if>
-            <if test="status != null">
-                status=#{status,jdbcType=INTEGER},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByPk" parameterType="string" resultMap="ResourcesResultMap">
-        SELECT * FROM S_RESOURCES WHERE u_id=#{u_id}
+        select * from s_resources WHERE u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="ResourcesResultMap">

+ 18 - 25
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/role/RoleMapper.xml

@@ -5,7 +5,6 @@
 <mapper namespace="org.hsweb.web.dao.role.RoleMapper">
     <resultMap id="RoleResultMap" type="Role">
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
         <result property="remark" column="remark" javaType="String" jdbcType="VARCHAR"/>
         <result property="type" column="type" javaType="String" jdbcType="VARCHAR"/>
@@ -16,44 +15,38 @@
     <!--字段信息绑定-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','name':'string','remark':'string','type':'string'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'remark':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'type':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    }"/>
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
 
     <!--表名-->
     <sql id="tableName">
-        <bind name="$tableName" value="'S_ROLE'"/>
+        <bind name="$tableName" value="'s_role'"/>
     </sql>
 
-    <insert id="insert" parameterType="Role" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_ROLE
-        (u_id,name,remark,type)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR})
+    <insert id="insert" parameterType="Role" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="Role">
-        DELETE FROM S_ROLE WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_role where u_id=#{term.primaryKey}
     </delete>
 
-    <update id="update" parameterType="Role">
-        UPDATE S_ROLE
-        <set>
-            <if test="name != null">
-                name=#{name,jdbcType=VARCHAR},
-            </if>
-            <if test="remark != null">
-                remark=#{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="type != null">
-                type=#{type,jdbcType=VARCHAR},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByPk" parameterType="string" resultMap="RoleResultMap">
-        SELECT * FROM S_ROLE WHERE u_id=#{u_id}
+        select * from s_role where u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="RoleResultMap">

+ 23 - 28
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/role/RoleModuleMapper.xml

@@ -6,7 +6,6 @@
 <mapper namespace="org.hsweb.web.dao.role.RoleModuleMapper">
     <resultMap id="RoleModuleResultMap" type="RoleModule" >
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR" />
         <result property="module_id" column="module_id" javaType="String" jdbcType="VARCHAR" />
         <result property="role_id" column="role_id" javaType="String" jdbcType="VARCHAR" />
         <result property="o_level" column="o_level" javaType="String" jdbcType="VARCHAR" />
@@ -15,55 +14,51 @@
 
     <!--字段信息绑定-->
     <sql id="fieldConfig">
-        <bind name="$fieldsInfo" value="#{'u_id':'string','module_id':'string','role_id':'string','o_level':'string'}"/>
+        <bind name="$fieldsInfo"
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'module_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'role_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'content':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'o_level':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    }"/>
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
     <!--表名-->
     <sql id="tableName">
-        <bind name="$tableName" value="'S_ROLE_MODULES'"/>
+        <bind name="$tableName" value="'s_role_modules'"/>
     </sql>
 
-    <insert id="insert" parameterType="RoleModule" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_ROLE_MODULES
-        (u_id,module_id,role_id,o_level)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{module_id,jdbcType=VARCHAR},#{role_id,jdbcType=VARCHAR},#{o_level,jdbcType=VARCHAR})
+    <insert id="insert" parameterType="RoleModule" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="RoleModule" >
-        DELETE FROM S_ROLE_MODULES WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_role_modules where u_id=#{term.primaryKey}
     </delete>
 
     <delete id="deleteByRoleId" parameterType="string" >
-        DELETE FROM S_ROLE_MODULES WHERE role_id=#{role_id}
+        delete from s_role_modules where role_id=#{role_id}
     </delete>
 
     <delete id="deleteByModuleId" parameterType="string" >
-        DELETE FROM S_ROLE_MODULES WHERE module_id=#{module_id}
+        delete from s_role_modules where module_id=#{module_id}
     </delete>
 
-    <update id="update" parameterType="RoleModule" >
-        UPDATE S_ROLE_MODULES
-        <set>
-            <if test="module_id != null">
-                module_id=#{module_id,jdbcType=VARCHAR},
-            </if>
-            <if test="role_id != null">
-                role_id=#{role_id,jdbcType=VARCHAR},
-            </if>
-            <if test="o_level != null">
-                o_level=#{o_level,jdbcType=VARCHAR},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByRoleId" parameterType="string" resultMap="RoleModuleResultMap">
-        SELECT * FROM S_ROLE_MODULES WHERE role_id=#{role_id}
+        select * from s_role_modules where role_id=#{role_id}
     </select>
 
     <select id="selectByPk" parameterType="string" resultMap="RoleModuleResultMap">
-        SELECT * FROM S_ROLE_MODULES WHERE u_id=#{u_id}
+        select * from s_role_modules where u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="RoleModuleResultMap">

+ 18 - 26
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/role/UserRoleMapper.xml

@@ -6,7 +6,6 @@
 <mapper namespace="org.hsweb.web.dao.role.UserRoleMapper">
     <resultMap id="UserRoleResultMap" type="UserRole">
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="user_id" column="user_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="role_id" column="role_id" javaType="String" jdbcType="VARCHAR"/>
         <collection property="role" column="role_id" jdbcType="VARCHAR" ofType="Role"
@@ -15,7 +14,12 @@
 
     <!--字段信息配置-->
     <sql id="fieldConfig">
-        <bind name="$fieldsInfo" value="#{'u_id':'string','user_id':'string','role_id':'string'}"/>
+        <bind name="$fieldsInfo"
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'user_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'role_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    }"/>
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
 
@@ -24,40 +28,28 @@
         <bind name="$tableName" value="'S_USER_ROLE'"/>
     </sql>
 
-    <insert id="insert" parameterType="UserRole" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_USER_ROLE
-        (u_id,user_id,role_id)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{user_id,jdbcType=VARCHAR},#{role_id,jdbcType=VARCHAR})
+    <insert id="insert" parameterType="UserRole" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="UserRole">
-        DELETE FROM S_USER_ROLE WHERE u_id=#{u_id}
-    </delete>
-
-    <delete id="deleteByUserId" parameterType="string">
-        DELETE FROM S_USER_ROLE WHERE user_id=#{user_id}
+    <delete id="delete" parameterType="org.hsweb.web.bean.common.DeleteParam">
+        delete from s_user_role where u_id=#{term.primaryKey}
     </delete>
 
-    <update id="update" parameterType="UserRole">
-        UPDATE S_USER_ROLE
-        <set>
-            <if test="user_id != null">
-                user_id=#{user_id,jdbcType=VARCHAR},
-            </if>
-            <if test="role_id != null">
-                role_id=#{role_id,jdbcType=VARCHAR},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByUserId" parameterType="string" resultMap="UserRoleResultMap">
-        SELECT * FROM S_USER_ROLE WHERE user_id=#{user_id}
+        select * from s_user_role where user_id=#{user_id}
     </select>
 
     <select id="selectByPk" parameterType="string" resultMap="UserRoleResultMap">
-        SELECT * FROM S_USER_ROLE WHERE u_id=#{u_id}
+        select * from s_user_role where u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserRoleResultMap">

+ 20 - 32
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/script/DynamicScriptMapper.xml

@@ -6,7 +6,6 @@
 <mapper namespace="org.hsweb.web.dao.script.DynamicScriptMapper">
     <resultMap id="DynamicScriptResultMap" type="DynamicScript" >
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR" />
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR" />
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR" />
         <result property="type" column="type" javaType="String" jdbcType="VARCHAR" />
         <result property="content" column="content" javaType="String" jdbcType="VARCHAR" />
@@ -18,7 +17,16 @@
     <!--字段配置-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','name':'string','type':'string','content':'string','remark':'string','path':'string','status':'number'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'type':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'content':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'remark':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'path':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'status':#{'jdbcType':'INTEGER','javaType':'int'}
+                    }"/>
+
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
 
@@ -27,40 +35,20 @@
         <bind name="$tableName" value="'S_SCRIPT'"/>
     </sql>
 
-    <insert id="insert" parameterType="DynamicScript" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_SCRIPT
-        (u_id,name,type,content,remark,path,status)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{type,jdbcType=VARCHAR},#{content,jdbcType=VARCHAR},#{remark,jdbcType=VARCHAR},#{path,jdbcType=VARCHAR},#{status,jdbcType=INTEGER})
+    <insert id="insert" parameterType="DynamicScript" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="DynamicScript" >
-        DELETE FROM S_SCRIPT WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="UserRole">
+        delete from s_user_role where u_id=#{u_id}
     </delete>
 
-    <update id="update" parameterType="DynamicScript" >
-        UPDATE S_SCRIPT
-        <set>
-            <if test="name != null">
-                name=#{name,jdbcType=VARCHAR},
-            </if>
-            <if test="type != null">
-                type=#{type,jdbcType=VARCHAR},
-            </if>
-            <if test="content != null">
-                content=#{content,jdbcType=VARCHAR},
-            </if>
-            <if test="remark != null">
-                remark=#{remark,jdbcType=VARCHAR},
-            </if>
-            <if test="path != null">
-                path=#{path,jdbcType=VARCHAR},
-            </if>
-            <if test="status != null">
-                status=#{status,jdbcType=INTEGER},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByPk" parameterType="string" resultMap="DynamicScriptResultMap">

+ 25 - 35
hsweb-web-dao-impl-mybatis/src/main/resources/org/hsweb/web/dao/impl/mybatis/mapper/mysql/user/UserMapper.xml

@@ -6,7 +6,6 @@
 <mapper namespace="org.hsweb.web.dao.user.UserMapper">
     <resultMap id="UserResultMap" type="User">
         <id property="u_id" column="u_id" javaType="string" jdbcType="VARCHAR"/>
-        <result property="u_id" column="u_id" javaType="String" jdbcType="VARCHAR"/>
         <result property="username" column="username" javaType="String" jdbcType="VARCHAR"/>
         <result property="password" column="password" javaType="String" jdbcType="VARCHAR"/>
         <result property="name" column="name" javaType="String" jdbcType="VARCHAR"/>
@@ -21,59 +20,50 @@
     <!--字段信息配置-->
     <sql id="fieldConfig">
         <bind name="$fieldsInfo"
-              value="#{'u_id':'string','username':'string','name':'string'
-                    ,'email':'string','phone':'string','status':'number'
-                    ,'create_date':'date','update_date':'date'}"/>
+              value="#{
+                    'u_id':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'username':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'password':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'name':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'email':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'phone':#{'jdbcType':'VARCHAR','javaType':'string'}
+                    ,'status':#{'jdbcType':'INTEGER','javaType':'number'}
+                    ,'create_date':#{'jdbcType':'TIMESTAMP','javaType':'date'}
+                    ,'update_date':#{'jdbcType':'TIMESTAMP','javaType':'date'}
+                    }"/>
         <bind name="$fields" value="$fieldsInfo.keySet()"/>
     </sql>
     <!--表名-->
     <sql id="tableName">
-        <bind name="$tableName" value="'S_USER'"/>
+        <bind name="$tableName" value="'s_user'"/>
     </sql>
 
-    <insert id="insert" parameterType="User" useGeneratedKeys="true" keyProperty="u_id" keyColumn="U_ID">
-        INSERT INTO S_USER
-        (u_id,username,password,name,email,phone,status,create_date,update_date)
-        VALUES
-        (#{u_id,jdbcType=VARCHAR},#{username,jdbcType=VARCHAR},#{password,jdbcType=VARCHAR},#{name,jdbcType=VARCHAR},#{email,jdbcType=VARCHAR},#{phone,jdbcType=VARCHAR},#{status,jdbcType=INTEGER},#{create_date,jdbcType=TIMESTAMP},#{update_date,jdbcType=TIMESTAMP})
+    <insert id="insert" parameterType="User" useGeneratedKeys="true" keyProperty="data.u_id" keyColumn="U_ID">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildInsertSql"/>
     </insert>
 
-    <delete id="delete" parameterType="User">
-        DELETE FROM S_USER WHERE u_id=#{u_id}
+    <delete id="delete" parameterType="UserRole">
+        delete from s_user where u_id=#{u_id}
     </delete>
 
     <update id="updatePassword" parameterType="User">
-        UPDATE S_USER set password=#{password,jdbcType=VARCHAR} where u_id = #{u_id}
+        update s_user set password=#{password,jdbcType=VARCHAR} where u_id = #{u_id}
     </update>
 
-    <update id="update" parameterType="User">
-        UPDATE S_USER
-        <set>
-            <if test="name != null">
-                name=#{name,jdbcType=VARCHAR},
-            </if>
-            <if test="email != null">
-                email=#{email,jdbcType=VARCHAR},
-            </if>
-            <if test="phone != null">
-                phone=#{phone,jdbcType=VARCHAR},
-            </if>
-            <if test="status != null">
-                status=#{status,jdbcType=INTEGER},
-            </if>
-            <if test="update_date != null">
-                update_date=#{update_date,jdbcType=TIMESTAMP},
-            </if>
-        </set>
-        WHERE u_id=#{u_id}
+    <update id="update" parameterType="org.hsweb.web.bean.common.UpdateParam">
+        <include refid="fieldConfig"/>
+        <include refid="tableName"/>
+        <include refid="BasicMapper.buildUpdateSql"/>
     </update>
 
     <select id="selectByUserName" parameterType="string" resultMap="UserResultMap">
-        SELECT * FROM S_USER WHERE username=#{username}
+        select * from s_user where username=#{username}
     </select>
 
     <select id="selectByPk" parameterType="string" resultMap="UserResultMap">
-        SELECT * FROM S_USER WHERE u_id=#{u_id}
+        select * from s_user where u_id=#{u_id}
     </select>
 
     <select id="select" parameterType="org.hsweb.web.bean.common.QueryParam" resultMap="UserResultMap">