<?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.wechat.dao.MdeIntvTimeDao" >
  <resultMap id="BaseResultMap" type="com.wechat.model.dbEntity.MdeIntvTime">
    <id column="INTV_TIME_ID" jdbcType="INTEGER" property="intvTimeId" />
    <result column="INTV_ID" jdbcType="INTEGER" property="intvId" />
    <result column="INTV_TIME_FROM" jdbcType="TIMESTAMP" property="intvTimeFrom" />
    <result column="INTV_TIME_TO" jdbcType="TIMESTAMP" property="intvTimeTo" />
    <result column="CONFIRMED_BY" jdbcType="VARCHAR" property="confirmedBy" />
    <result column="SORT" jdbcType="INTEGER" property="sort" />
    <result column="STATUS" jdbcType="CHAR" property="status" />
    <result column="VERSION_NO" jdbcType="INTEGER" property="versionNo" />
    <result column="CREATE_BY" jdbcType="VARCHAR" property="createBy" />
    <result column="CREATE_DATE" jdbcType="TIMESTAMP" property="createDate" />
    <result column="UPDATE_BY" jdbcType="VARCHAR" property="updateBy" />
    <result column="UPDATE_DATE" jdbcType="TIMESTAMP" property="updateDate" />
    <result column="REMARKS" jdbcType="VARCHAR" property="remarks" />
    <result column="DEL_FLAG" jdbcType="CHAR" property="delFlag" />
    <result column="CONTENT" jdbcType="LONGVARCHAR" property="content" />
  </resultMap>
  <sql id="Base_Column_List">
    INTV_TIME_ID, INTV_ID, INTV_TIME_FROM, INTV_TIME_TO, CONTENT,CONFIRMED_BY, SORT,STATUS, VERSION_NO, 
    CREATE_BY, CREATE_DATE, UPDATE_BY, UPDATE_DATE, REMARKS, DEL_FLAG
  </sql>

  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from mde_intv_time
    where INTV_TIME_ID = #{intvTimeId,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.wechat.model.dbEntity.MdeIntvTime">
    insert into mde_intv_time (INTV_ID, INTV_TIME_FROM, 
      INTV_TIME_TO, CONFIRMED_BY, SORT, STATUS, 
      CREATE_BY, CREATE_DATE, 
      UPDATE_BY, UPDATE_DATE, REMARKS, 
      CONTENT)
    values (#{intvId}, #{intvTimeFrom}, 
      #{intvTimeTo}, #{confirmedBy,jdbcType=VARCHAR}, #{sort}, #{status,jdbcType=CHAR}, 
      #{createBy,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, 
      #{updateBy,jdbcType=VARCHAR}, #{updateDate,jdbcType=TIMESTAMP}, #{remarks,jdbcType=VARCHAR}, 
      #{content,jdbcType=LONGVARCHAR})
  </insert>
  
  <update id="updateByPrimaryKeySelective" parameterType="com.wechat.model.dbEntity.MdeIntvTime">
    update mde_intv_time
    <set>
      <if test="intvId != null">
        INTV_ID = #{intvId,jdbcType=INTEGER},
      </if>
      <if test="intvTimeFrom != null">
        INTV_TIME_FROM = #{intvTimeFrom,jdbcType=TIMESTAMP},
      </if>
      <if test="intvTimeTo != null">
        INTV_TIME_TO = #{intvTimeTo,jdbcType=TIMESTAMP},
      </if>
      <if test="confirmedBy != null">
        CONFIRMED_BY = #{confirmedBy,jdbcType=VARCHAR},
      </if>
       <if test="sort != null">
        SORT = #{sort},
      </if>
      <if test="status != null">
        STATUS = #{status,jdbcType=CHAR},
      </if>
      <if test="versionNo != null">
        VERSION_NO = #{versionNo,jdbcType=INTEGER},
      </if>
      <if test="createBy != null">
        CREATE_BY = #{createBy,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null">
        CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="updateBy != null">
        UPDATE_BY = #{updateBy,jdbcType=VARCHAR},
      </if>
      <if test="updateDate != null">
        UPDATE_DATE = #{updateDate,jdbcType=TIMESTAMP},
      </if>
      <if test="remarks != null">
        REMARKS = #{remarks,jdbcType=VARCHAR},
      </if>
      <if test="delFlag != null">
        DEL_FLAG = #{delFlag,jdbcType=CHAR},
      </if>
      <if test="content != null">
        CONTENT = #{content,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where INTV_TIME_ID = #{intvTimeId,jdbcType=INTEGER}
  </update>
  
  <update id="cancelIntvTime" parameterType="com.wechat.model.dbEntity.MdeIntvTime">
    update mde_intv_time
    set 
      STATUS = '1',
      <if test="updateBy != null and updateBy != ''"> 
      	update_by = #{updateBy},
      </if>
	  <if test="updateDate != null">
	  	update_date = #{updateDate},
	  </if>
      version_no = version_no +1
    where INTV_ID = #{intvId}
      and STATUS = '0'
      <if test="confirmedBy != null and confirmedBy != ''"> 
      	and CONFIRMED_BY = #{confirmedBy}
      </if>
  </update>
  <update id="updateByPrimaryKey" parameterType="com.wechat.model.dbEntity.MdeIntvTime">
    update mde_intv_time
    set INTV_ID = #{intvId,jdbcType=INTEGER},
      INTV_TIME_FROM = #{intvTimeFrom,jdbcType=TIMESTAMP},
      INTV_TIME_TO = #{intvTimeTo,jdbcType=TIMESTAMP},
      CONFIRMED_BY = #{confirmedBy,jdbcType=VARCHAR},
      STATUS = #{status,jdbcType=CHAR},
      VERSION_NO = #{versionNo,jdbcType=INTEGER},
      CREATE_BY = #{createBy,jdbcType=VARCHAR},
      CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      UPDATE_BY = #{updateBy,jdbcType=VARCHAR},
      UPDATE_DATE = #{updateDate,jdbcType=TIMESTAMP},
      REMARKS = #{remarks,jdbcType=VARCHAR},
      DEL_FLAG = #{delFlag,jdbcType=CHAR}
    where INTV_TIME_ID = #{intvTimeId,jdbcType=INTEGER}
  </update>
  
</mapper>