<?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="com.th.demo.mapping.develop.DevBussinessTableMapper">
    <resultMap id="BaseResultMap" type="com.th.demo.model.develop.DevBussinessTable" >
        <id column="ID" property="id" jdbcType="VARCHAR" />
        <result column="BUSSINESS_NAME" property="bussinessName" jdbcType="VARCHAR" />
        <result column="DB_TABLE_NAME" property="dbTableName" jdbcType="VARCHAR" />
        <result column="PROCESS_NAME" property="processName" jdbcType="VARCHAR" />
        <result column="PACKAGE_NAME" property="packageName" jdbcType="VARCHAR" />
        <result column="ADD_ID" property="addId" jdbcType="VARCHAR" />
        <result column="ADD_TIME" property="addTime" jdbcType="TIMESTAMP" />
        <result column="MODIFY_ID" property="modifyId" jdbcType="VARCHAR" />
        <result column="MODIFY_TIME" property="modifyTime" jdbcType="TIMESTAMP" />
        <result column="CANCEL_ID" property="cancelId" jdbcType="VARCHAR" />
        <result column="CANCEL_TIME" property="cancelTime" jdbcType="TIMESTAMP" />
        <result column="CANCEL_FLAG" property="cancelFlag" jdbcType="VARCHAR" />
        <result column="ATTR1" property="attr1" jdbcType="VARCHAR" />
        <result column="ATTR2" property="attr2" jdbcType="VARCHAR" />
        <result column="ATTR3" property="attr3" jdbcType="VARCHAR" />
        <result column="ATTR4" property="attr4" jdbcType="DECIMAL" />
        <result column="ATTR5" property="attr5" jdbcType="DECIMAL" />
        <result column="ATTR6" property="attr6" jdbcType="DECIMAL" />
        <result column="MODULE_NAME" property="moduleName" jdbcType="VARCHAR" />
    </resultMap>

    <resultMap id="DevCodeMechine" type="com.th.demo.model.develop.DevCodeMechine">
        <result column="COLUMN_NAME" property="columnName" jdbcType="VARCHAR"/>
        <result column="PROPERTY_NAME" property="propertyName" jdbcType="VARCHAR"/>
        <result column="DATA_TYPE" property="dataType" jdbcType="VARCHAR"/>
        <result column="COMMENTS" property="comments" jdbcType="VARCHAR"/>
        <result column="SET_FUNCTION" property="setFunction" jdbcType="VARCHAR"/>

    </resultMap>



    <sql id="Base_Column_List" >
        ID, BUSSINESS_NAME, DB_TABLE_NAME, PROCESS_NAME, PACKAGE_NAME, ADD_ID, ADD_TIME,
        MODIFY_ID, MODIFY_TIME, CANCEL_ID, CANCEL_TIME, CANCEL_FLAG, ATTR1, ATTR2, ATTR3,
        ATTR4, ATTR5, ATTR6, MODULE_NAME
    </sql>
    <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
        select
        <include refid="Base_Column_List" />
        from DEV_BUSSINESS_TABLE
        where ID = #{id,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
        delete from DEV_BUSSINESS_TABLE
        where ID = #{id,jdbcType=VARCHAR}
    </delete>
    <insert id="insert" parameterType="com.th.demo.model.develop.DevBussinessTable" >
        <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">
            SELECT  REPLACE(UUID(),'-','') as id from dual
        </selectKey>


        insert into DEV_BUSSINESS_TABLE (ID, BUSSINESS_NAME, DB_TABLE_NAME,
        PROCESS_NAME, PACKAGE_NAME, ADD_ID,
        ADD_TIME, MODIFY_ID, MODIFY_TIME,
        CANCEL_ID, CANCEL_TIME, CANCEL_FLAG,
        ATTR1, ATTR2, ATTR3,
        ATTR4, ATTR5, ATTR6,
        MODULE_NAME)
        values (#{id,jdbcType=VARCHAR}, #{bussinessName,jdbcType=VARCHAR}, #{dbTableName,jdbcType=VARCHAR},
        #{processName,jdbcType=VARCHAR}, #{packageName,jdbcType=VARCHAR}, #{addId,jdbcType=VARCHAR},
        #{addTime,jdbcType=TIMESTAMP}, #{modifyId,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP},
        #{cancelId,jdbcType=VARCHAR}, #{cancelTime,jdbcType=TIMESTAMP}, #{cancelFlag,jdbcType=VARCHAR},
        #{attr1,jdbcType=VARCHAR}, #{attr2,jdbcType=VARCHAR}, #{attr3,jdbcType=VARCHAR},
        #{attr4,jdbcType=DECIMAL}, #{attr5,jdbcType=DECIMAL}, #{attr6,jdbcType=DECIMAL},
        #{moduleName,jdbcType=VARCHAR})
    </insert>
    <insert id="insertSelective" parameterType="com.th.demo.model.develop.DevBussinessTable" >
        insert into DEV_BUSSINESS_TABLE
        <trim prefix="(" suffix=")" suffixOverrides="," >
            <if test="id != null" >
                ID,
            </if>
            <if test="bussinessName != null" >
                BUSSINESS_NAME,
            </if>
            <if test="dbTableName != null" >
                DB_TABLE_NAME,
            </if>
            <if test="processName != null" >
                PROCESS_NAME,
            </if>
            <if test="packageName != null" >
                PACKAGE_NAME,
            </if>
            <if test="addId != null" >
                ADD_ID,
            </if>
            <if test="addTime != null" >
                ADD_TIME,
            </if>
            <if test="modifyId != null" >
                MODIFY_ID,
            </if>
            <if test="modifyTime != null" >
                MODIFY_TIME,
            </if>
            <if test="cancelId != null" >
                CANCEL_ID,
            </if>
            <if test="cancelTime != null" >
                CANCEL_TIME,
            </if>
            <if test="cancelFlag != null" >
                CANCEL_FLAG,
            </if>
            <if test="attr1 != null" >
                ATTR1,
            </if>
            <if test="attr2 != null" >
                ATTR2,
            </if>
            <if test="attr3 != null" >
                ATTR3,
            </if>
            <if test="attr4 != null" >
                ATTR4,
            </if>
            <if test="attr5 != null" >
                ATTR5,
            </if>
            <if test="attr6 != null" >
                ATTR6,
            </if>
            <if test="moduleName != null" >
                MODULE_NAME,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides="," >
            <if test="id != null" >
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="bussinessName != null" >
                #{bussinessName,jdbcType=VARCHAR},
            </if>
            <if test="dbTableName != null" >
                #{dbTableName,jdbcType=VARCHAR},
            </if>
            <if test="processName != null" >
                #{processName,jdbcType=VARCHAR},
            </if>
            <if test="packageName != null" >
                #{packageName,jdbcType=VARCHAR},
            </if>
            <if test="addId != null" >
                #{addId,jdbcType=VARCHAR},
            </if>
            <if test="addTime != null" >
                #{addTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyId != null" >
                #{modifyId,jdbcType=VARCHAR},
            </if>
            <if test="modifyTime != null" >
                #{modifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="cancelId != null" >
                #{cancelId,jdbcType=VARCHAR},
            </if>
            <if test="cancelTime != null" >
                #{cancelTime,jdbcType=TIMESTAMP},
            </if>
            <if test="cancelFlag != null" >
                #{cancelFlag,jdbcType=VARCHAR},
            </if>
            <if test="attr1 != null" >
                #{attr1,jdbcType=VARCHAR},
            </if>
            <if test="attr2 != null" >
                #{attr2,jdbcType=VARCHAR},
            </if>
            <if test="attr3 != null" >
                #{attr3,jdbcType=VARCHAR},
            </if>
            <if test="attr4 != null" >
                #{attr4,jdbcType=DECIMAL},
            </if>
            <if test="attr5 != null" >
                #{attr5,jdbcType=DECIMAL},
            </if>
            <if test="attr6 != null" >
                #{attr6,jdbcType=DECIMAL},
            </if>
            <if test="moduleName != null" >
                #{moduleName,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
    <update id="updateByPrimaryKeySelective" parameterType="com.th.demo.model.develop.DevBussinessTable" >
        update DEV_BUSSINESS_TABLE
        <set >
            <if test="bussinessName != null" >
                BUSSINESS_NAME = #{bussinessName,jdbcType=VARCHAR},
            </if>
            <if test="dbTableName != null" >
                DB_TABLE_NAME = #{dbTableName,jdbcType=VARCHAR},
            </if>
            <if test="processName != null" >
                PROCESS_NAME = #{processName,jdbcType=VARCHAR},
            </if>
            <if test="packageName != null" >
                PACKAGE_NAME = #{packageName,jdbcType=VARCHAR},
            </if>
            <if test="addId != null" >
                ADD_ID = #{addId,jdbcType=VARCHAR},
            </if>
            <if test="addTime != null" >
                ADD_TIME = #{addTime,jdbcType=TIMESTAMP},
            </if>
            <if test="modifyId != null" >
                MODIFY_ID = #{modifyId,jdbcType=VARCHAR},
            </if>
            <if test="modifyTime != null" >
                MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
            </if>
            <if test="cancelId != null" >
                CANCEL_ID = #{cancelId,jdbcType=VARCHAR},
            </if>
            <if test="cancelTime != null" >
                CANCEL_TIME = #{cancelTime,jdbcType=TIMESTAMP},
            </if>
            <if test="cancelFlag != null" >
                CANCEL_FLAG = #{cancelFlag,jdbcType=VARCHAR},
            </if>
            <if test="attr1 != null" >
                ATTR1 = #{attr1,jdbcType=VARCHAR},
            </if>
            <if test="attr2 != null" >
                ATTR2 = #{attr2,jdbcType=VARCHAR},
            </if>
            <if test="attr3 != null" >
                ATTR3 = #{attr3,jdbcType=VARCHAR},
            </if>
            <if test="attr4 != null" >
                ATTR4 = #{attr4,jdbcType=DECIMAL},
            </if>
            <if test="attr5 != null" >
                ATTR5 = #{attr5,jdbcType=DECIMAL},
            </if>
            <if test="attr6 != null" >
                ATTR6 = #{attr6,jdbcType=DECIMAL},
            </if>
            <if test="moduleName != null" >
                MODULE_NAME = #{moduleName,jdbcType=VARCHAR},
            </if>
        </set>
        where ID = #{id,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey" parameterType="com.th.demo.model.develop.DevBussinessTable" >
    update DEV_BUSSINESS_TABLE
    set BUSSINESS_NAME = #{bussinessName,jdbcType=VARCHAR},
      DB_TABLE_NAME = #{dbTableName,jdbcType=VARCHAR},
      PROCESS_NAME = #{processName,jdbcType=VARCHAR},
      PACKAGE_NAME = #{packageName,jdbcType=VARCHAR},
      ADD_ID = #{addId,jdbcType=VARCHAR},
      ADD_TIME = #{addTime,jdbcType=TIMESTAMP},
      MODIFY_ID = #{modifyId,jdbcType=VARCHAR},
      MODIFY_TIME = #{modifyTime,jdbcType=TIMESTAMP},
      CANCEL_ID = #{cancelId,jdbcType=VARCHAR},
      CANCEL_TIME = #{cancelTime,jdbcType=TIMESTAMP},
      CANCEL_FLAG = #{cancelFlag,jdbcType=VARCHAR},
      ATTR1 = #{attr1,jdbcType=VARCHAR},
      ATTR2 = #{attr2,jdbcType=VARCHAR},
      ATTR3 = #{attr3,jdbcType=VARCHAR},
      ATTR4 = #{attr4,jdbcType=DECIMAL},
      ATTR5 = #{attr5,jdbcType=DECIMAL},
      ATTR6 = #{attr6,jdbcType=DECIMAL},
      MODULE_NAME = #{moduleName,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=VARCHAR}
  </update>


    <select id="selectFeildByTableName" resultMap="DevCodeMechine">
   SELECT column_name,column_comment as COMMENTS,data_type,'' as set_function,'' as property_name
      FROM information_schema.columns
    WHERE TABLE_NAME = #{param1,jdbcType=VARCHAR}
  </select>

    <select id="select" resultMap="BaseResultMap">

        SELECT * from DEV_BUSSINESS_TABLE where ifnull(CANCEL_FLAG,'0') !='9'
      and  DB_TABLE_NAME like '%'|| #{param1,jdbcType=VARCHAR} ||'%'

    </select>
    <select id="selectByTableName" resultMap="BaseResultMap">

        SELECT * from DEV_BUSSINESS_TABLE
        WHERE  DB_TABLE_NAME = #{param1,jdbcType=VARCHAR}
        and   ifnull(CANCEL_FLAG,'0') !='9'
    </select>

    <select id="selectByProcessName" resultMap="BaseResultMap">
        SELECT * from DEV_BUSSINESS_TABLE
        WHERE  PROCESS_NAME = #{param1,jdbcType=VARCHAR}
        and   ifnull(CANCEL_FLAG,'0') !='9'
    </select>
    <select id="selectByTableNameSingleResult" resultMap="BaseResultMap">

        SELECT * from DEV_BUSSINESS_TABLE
        WHERE  DB_TABLE_NAME = #{param1,jdbcType=VARCHAR}
        and   ifnull(CANCEL_FLAG,'0') !='9'
    </select>
    <select id="selectByProcessDefinitionId" resultMap="BaseResultMap">
        SELECT * from DEV_BUSSINESS_TABLE
        WHERE  PROCESS_NAME = #{param1,jdbcType=VARCHAR}
        and   ifnull(CANCEL_FLAG,'0') !='9'
    </select>

</mapper>