<?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.system.SysDicMapper" >
  <resultMap id="BaseResultMap" type="com.th.demo.model.system.SysDic" >
    <id column="ID" property="id" jdbcType="VARCHAR" />
    <result column="DIC_CODE" property="dicCode" jdbcType="VARCHAR" />
    <result column="DIC_NAME" property="dicName" jdbcType="VARCHAR" />
    <result column="DIC_TYPE" property="dicType" jdbcType="VARCHAR" />
    <result column="ORDER_BY" property="orderBy" jdbcType="DECIMAL" />
    <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" />
  </resultMap>
  <sql id="Base_Column_List" >
    ID, DIC_CODE, DIC_NAME, DIC_TYPE, ORDER_BY, ADD_ID, ADD_TIME, MODIFY_ID, MODIFY_TIME, 
    CANCEL_ID, CANCEL_TIME, CANCEL_FLAG, ATTR1, ATTR2, ATTR3, ATTR4, ATTR5, ATTR6
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select 
    <include refid="Base_Column_List" />
    from SYS_DIC
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from SYS_DIC
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.th.demo.model.system.SysDic" >
    <selectKey keyProperty="id" order="BEFORE" resultType="java.lang.String">
      SELECT  REPLACE(UUID(),'-','') as id from dual
    </selectKey>
    insert into sys_dic (ID, DIC_CODE, DIC_NAME,
      DIC_TYPE, ORDER_BY, ADD_ID, 
      ADD_TIME, MODIFY_ID, MODIFY_TIME, 
      CANCEL_ID, CANCEL_TIME, CANCEL_FLAG, 
      ATTR1, ATTR2, ATTR3, 
      ATTR4, ATTR5, ATTR6
      )
    values (REPLACE(UUID(),'-',''), #{dicCode,jdbcType=VARCHAR}, #{dicName,jdbcType=VARCHAR},
      #{dicType,jdbcType=VARCHAR}, #{orderBy,jdbcType=DECIMAL}, #{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}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.th.demo.model.system.SysDic" >
    insert into SYS_DIC
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="dicCode != null" >
        DIC_CODE,
      </if>
      <if test="dicName != null" >
        DIC_NAME,
      </if>
      <if test="dicType != null" >
        DIC_TYPE,
      </if>
      <if test="orderBy != null" >
        ORDER_BY,
      </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>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="dicCode != null" >
        #{dicCode,jdbcType=VARCHAR},
      </if>
      <if test="dicName != null" >
        #{dicName,jdbcType=VARCHAR},
      </if>
      <if test="dicType != null" >
        #{dicType,jdbcType=VARCHAR},
      </if>
      <if test="orderBy != null" >
        #{orderBy,jdbcType=DECIMAL},
      </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>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.th.demo.model.system.SysDic" >
    update SYS_DIC
    <set >
      <if test="dicCode != null" >
        DIC_CODE = #{dicCode,jdbcType=VARCHAR},
      </if>
      <if test="dicName != null" >
        DIC_NAME = #{dicName,jdbcType=VARCHAR},
      </if>
      <if test="dicType != null" >
        DIC_TYPE = #{dicType,jdbcType=VARCHAR},
      </if>
      <if test="orderBy != null" >
        ORDER_BY = #{orderBy,jdbcType=DECIMAL},
      </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>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.th.demo.model.system.SysDic" >
    update sys_dic
    set DIC_CODE = #{dicCode,jdbcType=VARCHAR},
      DIC_NAME = #{dicName,jdbcType=VARCHAR},
      DIC_TYPE = #{dicType,jdbcType=VARCHAR},
      ORDER_BY = #{orderBy,jdbcType=DECIMAL},
      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}
    where ID = #{id,jdbcType=VARCHAR}
  </update>

  <select id="selectByDicType" resultMap="BaseResultMap"   >
    select * from sys_dic
    where DIC_TYPE = #{param1,jdbcType=VARCHAR}
    order by order_by
  </select>

  <select id="selectByDicCode" resultMap="BaseResultMap"   >
    select
    <include refid="Base_Column_List" />
    from sys_dic
    where dic_code = #{param1,jdbcType=VARCHAR}
  </select>

  <select id="select" resultMap="BaseResultMap">
    select * from sys_dic where  dic_type like  CONCAT('%',#{param1,jdbcType=VARCHAR},'%') order by dic_type,order_by
  </select>

  <select id="selectByDic" parameterType="com.th.demo.model.system.SysDic" resultMap="BaseResultMap">
    select * from sys_dic where (DIC_CODE = #{dicCode,jdbcType=VARCHAR}
      or DIC_NAME = #{dicName,jdbcType=VARCHAR})
      and  DIC_TYPE = #{dicType,jdbcType=VARCHAR} order by dic_type,order_by
  </select>

</mapper>