<?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.SysLogMapper" >
  <resultMap id="BaseResultMap" type="com.th.demo.model.system.SysLog" >
    <id column="ID" property="id" jdbcType="VARCHAR" />
    <result column="LOG_IP" property="logIp" jdbcType="VARCHAR" />
    <result column="LOG_HOSTNAME" property="logHostname" jdbcType="VARCHAR" />
    <result column="LOG_JM_ID" property="logJmId" jdbcType="VARCHAR" />
    <result column="LOG_TYPE" property="logType" jdbcType="VARCHAR" />
    <result column="LOG_INFO" property="logInfo" 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" />
	    <association column="log_user_id" property="user"
                 javaType="com.th.demo.model.system.SysUser" select="com.th.demo.mapping.system.SysUserMapper.selectByPrimaryKey">
    </association>
  </resultMap>
  <sql id="Base_Column_List" >
    ID, LOG_IP, LOG_HOSTNAME, LOG_JM_ID, LOG_TYPE, LOG_INFO, 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_LOG
    where ID = #{id,jdbcType=VARCHAR}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.String" >
    delete from SYS_LOG
    where ID = #{id,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.th.demo.model.system.SysLog" >
    insert into SYS_LOG (ID, LOG_IP, LOG_HOSTNAME, 
      LOG_JM_ID, LOG_TYPE, LOG_INFO, 
      ADD_ID, ADD_TIME, MODIFY_ID, 
      MODIFY_TIME, CANCEL_ID, CANCEL_TIME, 
      CANCEL_FLAG, ATTR1, ATTR2, 
      ATTR3, ATTR4, ATTR5, 
      ATTR6)
    values (REPLACE(UUID(),'-',''), #{logIp,jdbcType=VARCHAR}, #{logHostname,jdbcType=VARCHAR},
      #{logJmId,jdbcType=VARCHAR}, #{logType,jdbcType=VARCHAR}, #{logInfo,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})
  </insert>
  <insert id="insertSelective" parameterType="com.th.demo.model.system.SysLog" >
    insert into SYS_LOG
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="logIp != null" >
        LOG_IP,
      </if>
      <if test="logHostname != null" >
        LOG_HOSTNAME,
      </if>
      <if test="logJmId != null" >
        LOG_JM_ID,
      </if>
      <if test="logType != null" >
        LOG_TYPE,
      </if>
      <if test="logInfo != null" >
        LOG_INFO,
      </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="logIp != null" >
        #{logIp,jdbcType=VARCHAR},
      </if>
      <if test="logHostname != null" >
        #{logHostname,jdbcType=VARCHAR},
      </if>
      <if test="logJmId != null" >
        #{logJmId,jdbcType=VARCHAR},
      </if>
      <if test="logType != null" >
        #{logType,jdbcType=VARCHAR},
      </if>
      <if test="logInfo != null" >
        #{logInfo,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>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.th.demo.model.system.SysLog" >
    update SYS_LOG
    <set >
      <if test="logIp != null" >
        LOG_IP = #{logIp,jdbcType=VARCHAR},
      </if>
      <if test="logHostname != null" >
        LOG_HOSTNAME = #{logHostname,jdbcType=VARCHAR},
      </if>
      <if test="logJmId != null" >
        LOG_JM_ID = #{logJmId,jdbcType=VARCHAR},
      </if>
      <if test="logType != null" >
        LOG_TYPE = #{logType,jdbcType=VARCHAR},
      </if>
      <if test="logInfo != null" >
        LOG_INFO = #{logInfo,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>
    </set>
    where ID = #{id,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.th.demo.model.system.SysLog" >
    update SYS_LOG
    set LOG_IP = #{logIp,jdbcType=VARCHAR},
      LOG_HOSTNAME = #{logHostname,jdbcType=VARCHAR},
      LOG_JM_ID = #{logJmId,jdbcType=VARCHAR},
      LOG_TYPE = #{logType,jdbcType=VARCHAR},
      LOG_INFO = #{logInfo,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}
    where ID = #{id,jdbcType=VARCHAR}
  </update>
    <select id="selectDateTime" resultType="java.lang.String"  >
    select SYSDATE()
  </select>
  <select id="selectByParam" resultMap="BaseResultMap">
    select t.*,d.user_name,d.user_desc
    <!-- <include refid="Base_Column_List" /> -->
    from sys_log t left join sys_user d on t.log_user_id = d.id
    where
    t.log_time between #{param1,jdbcType=TIMESTAMP} and #{param2,jdbcType=TIMESTAMP}
    and d.user_name like '%'||#{param3,jdbcType=VARCHAR}||'%'
    and d.user_desc like '%'||#{param4,jdbcType=VARCHAR}||'%'
    and t.log_ip like '%'||#{param5,jdbcType=VARCHAR}||'%'
    and t.log_hostname like '%'||#{param6,jdbcType=VARCHAR}||'%'
    and t.log_jm_id like '%'||#{param7,jdbcType=VARCHAR}||'%'
    and t.log_type like '%'||#{param8,jdbcType=VARCHAR}||'%'


  </select>
</mapper>