<?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.steerinfo.ems.tcmtimelist.mapper.TCmTimelistMapper">
  <resultMap id="BaseResultMap" type="com.steerinfo.ems.tcmtimelist.model.TCmTimelist">
    <id column="RECORDID" jdbcType="VARCHAR" property="recordid" />
    <result column="DEFID" jdbcType="VARCHAR" property="defid" />
    <result column="DEFNAME" jdbcType="VARCHAR" property="defname" />
    <result column="TIMEGRANID" jdbcType="VARCHAR" property="timegranid" />
    <result column="TIMEDEFAULT" jdbcType="VARCHAR" property="timedefault" />
    <result column="DESTTIME" jdbcType="VARCHAR" property="desttime" />
    <result column="STARTTIME" jdbcType="VARCHAR" property="starttime" />
    <result column="ENDTIME" jdbcType="VARCHAR" property="endtime" />
    <result column="TIMEFORMAT" jdbcType="VARCHAR" property="timeformat" />
  </resultMap>
  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select RECORDID, DEFID, DEFNAME, TIMEGRANID, TIMEDEFAULT, DESTTIME, STARTTIME, ENDTIME,
    TIMEFORMAT
    from T_CM_TIMELIST
    <where>
      <if test="defid != null and defid != ''">
        and DEFID = #{defid}
      </if>
      <if test="starttime != null and starttime != ''">
        <![CDATA[
            and STARTTIME >= #{starttime}
        ]]>
      </if>
      <if test="endtime != null and endtime != ''">
        <![CDATA[
            and ENDTIME <= #{endtime}
        ]]>
      </if>
    </where>
    order by STARTTIME
  </select>

  <insert id="batchInsert" parameterType="java.util.List">
    insert into T_CM_TIMELIST
    (RECORDID,
    DEFID, DEFNAME, TIMEGRANID,
    TIMEDEFAULT, DESTTIME, STARTTIME,
    ENDTIME, TIMEFORMAT)
    ( <foreach collection="list" item="item" separator="union all">
    select
    #{item.recordid,jdbcType=VARCHAR},
    #{item.defid,jdbcType=VARCHAR}, #{item.defname,jdbcType=VARCHAR}, #{item.timegranid,jdbcType=VARCHAR},
    #{item.timedefault,jdbcType=VARCHAR}, #{item.desttime,jdbcType=VARCHAR}, #{item.starttime,jdbcType=VARCHAR},
    #{item.endtime,jdbcType=VARCHAR}, #{item.timeformat,jdbcType=VARCHAR} from dual
  </foreach> )
  </insert>

  <delete id="deletebymodel" parameterType="com.steerinfo.ems.tcmtimelist.model.TCmTimelist">
    delete from T_CM_TIMELIST
    where 1=1
    <if test="defid != null and defid != ''">
      and DEFID = #{defid}
    </if>
    <if test="starttime != null and starttime != ''">
      <![CDATA[
            and STARTTIME >= #{starttime}
        ]]>
    </if>
    <if test="endtime != null and endtime != ''">
      <![CDATA[
            and ENDTIME <= #{endtime}
        ]]>
    </if>
  </delete>
  <!--
  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
    delete from T_CM_TIMELIST
    where 1=1
    <if test="defid != null and defid != ''">
      and DEFID = #{defid}
    </if>
    <if test="starttime != null and starttime != ''">
      <![CDATA[
            and STARTTIME >= #{starttime}
        ]]>
    </if>
    <if test="endtime != null and endtime != ''">
      <![CDATA[
            and ENDTIME <= #{endtime}
        ]]>
    </if>
  </delete>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from T_CM_TIMELIST
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </delete>
  <insert id="insert" parameterType="com.steerinfo.ems.tcmtimelist.model.TCmTimelist">
    insert into T_CM_TIMELIST (RECORDID, DEFID, DEFNAME,
      TIMEGRANID, TIMEDEFAULT, DESTTIME,
      STARTTIME, ENDTIME, TIMEFORMAT
      )
    values (#{recordid,jdbcType=VARCHAR}, #{defid,jdbcType=VARCHAR}, #{defname,jdbcType=VARCHAR},
      #{timegranid,jdbcType=VARCHAR}, #{timedefault,jdbcType=VARCHAR}, #{desttime,jdbcType=VARCHAR},
      #{starttime,jdbcType=VARCHAR}, #{endtime,jdbcType=VARCHAR}, #{timeformat,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.steerinfo.ems.tcmtimelist.model.TCmTimelist">
    insert into T_CM_TIMELIST
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="recordid != null">
        RECORDID,
      </if>
      <if test="defid != null">
        DEFID,
      </if>
      <if test="defname != null">
        DEFNAME,
      </if>
      <if test="timegranid != null">
        TIMEGRANID,
      </if>
      <if test="timedefault != null">
        TIMEDEFAULT,
      </if>
      <if test="desttime != null">
        DESTTIME,
      </if>
      <if test="starttime != null">
        STARTTIME,
      </if>
      <if test="endtime != null">
        ENDTIME,
      </if>
      <if test="timeformat != null">
        TIMEFORMAT,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="recordid != null">
        #{recordid,jdbcType=VARCHAR},
      </if>
      <if test="defid != null">
        #{defid,jdbcType=VARCHAR},
      </if>
      <if test="defname != null">
        #{defname,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="timedefault != null">
        #{timedefault,jdbcType=VARCHAR},
      </if>
      <if test="desttime != null">
        #{desttime,jdbcType=VARCHAR},
      </if>
      <if test="starttime != null">
        #{starttime,jdbcType=VARCHAR},
      </if>
      <if test="endtime != null">
        #{endtime,jdbcType=VARCHAR},
      </if>
      <if test="timeformat != null">
        #{timeformat,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.steerinfo.ems.tcmtimelist.model.TCmTimelist">
    update T_CM_TIMELIST
    set DEFID = #{defid,jdbcType=VARCHAR},
      DEFNAME = #{defname,jdbcType=VARCHAR},
      TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      TIMEDEFAULT = #{timedefault,jdbcType=VARCHAR},
      DESTTIME = #{desttime,jdbcType=VARCHAR},
      STARTTIME = #{starttime,jdbcType=VARCHAR},
      ENDTIME = #{endtime,jdbcType=VARCHAR},
      TIMEFORMAT = #{timeformat,jdbcType=VARCHAR}
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.ems.tcmtimelist.model.TCmTimelist">
    update T_CM_TIMELIST
    <set>
      <if test="defid != null">
        DEFID = #{defid,jdbcType=VARCHAR},
      </if>
      <if test="defname != null">
        DEFNAME = #{defname,jdbcType=VARCHAR},
      </if>
      <if test="timegranid != null">
        TIMEGRANID = #{timegranid,jdbcType=VARCHAR},
      </if>
      <if test="timedefault != null">
        TIMEDEFAULT = #{timedefault,jdbcType=VARCHAR},
      </if>
      <if test="desttime != null">
        DESTTIME = #{desttime,jdbcType=VARCHAR},
      </if>
      <if test="starttime != null">
        STARTTIME = #{starttime,jdbcType=VARCHAR},
      </if>
      <if test="endtime != null">
        ENDTIME = #{endtime,jdbcType=VARCHAR},
      </if>
      <if test="timeformat != null">
        TIMEFORMAT = #{timeformat,jdbcType=VARCHAR},
      </if>
    </set>
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </update>
  <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
    select RECORDID, DEFID, DEFNAME, TIMEGRANID, TIMEDEFAULT, DESTTIME, STARTTIME, ENDTIME,
    TIMEFORMAT
    from T_CM_TIMELIST
    where RECORDID = #{recordid,jdbcType=VARCHAR}
  </select>
  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
    select RECORDID, DEFID, DEFNAME, TIMEGRANID, TIMEDEFAULT, DESTTIME, STARTTIME, ENDTIME,
    TIMEFORMAT
    from T_CM_TIMELIST
    <where>
      <if test="defid != null and defid != ''">
        and DEFID LIKE '%${defid}%'
      </if>
      <if test="defname != null and defname != ''">
        and DEFNAME LIKE '%${defname}%'
      </if>
      <if test="timegranid != null and timegranid != ''">
        and TIMEGRANID LIKE '%${timegranid}%'
      </if>
      <if test="timedefault != null and timedefault != ''">
        and TIMEDEFAULT LIKE '%${timedefault}%'
      </if>
      <if test="desttime != null and desttime != ''">
        and DESTTIME LIKE '%${desttime}%'
      </if>
      <if test="starttime != null and starttime != ''">
        and STARTTIME LIKE '${starttime}%'
      </if>
      <if test="endtime != null and endtime != ''">
        and ENDTIME LIKE '${endtime}%'
      </if>
      <if test="timeformat != null and timeformat != ''">
        and TIMEFORMAT LIKE '%${timeformat}%'
      </if>
    </where>
  </select>

  <update id="batchUpdate" parameterType="java.util.List">
     update T_CM_TIMELIST
     set
       RECORDID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.recordid,jdbcType=VARCHAR}
       </foreach>
       ,DEFID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.defid,jdbcType=VARCHAR}
       </foreach>
       ,DEFNAME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.defname,jdbcType=VARCHAR}
       </foreach>
       ,TIMEGRANID=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.timegranid,jdbcType=VARCHAR}
       </foreach>
       ,TIMEDEFAULT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.timedefault,jdbcType=VARCHAR}
       </foreach>
       ,DESTTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.desttime,jdbcType=VARCHAR}
       </foreach>
       ,STARTTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.starttime,jdbcType=VARCHAR}
       </foreach>
       ,ENDTIME=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.endtime,jdbcType=VARCHAR}
       </foreach>
       ,TIMEFORMAT=
       <foreach collection="list" item="item" index="index" separator=" " open="case RECORDID" close="end">
          when #{item.recordid,jdbcType=VARCHAR} then #{item.timeformat,jdbcType=VARCHAR}
       </foreach>
     where RECORDID in
     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
    #{item.recordid,jdbcType=VARCHAR}
     </foreach>
  </update>
  <delete id="batchDelete" parameterType="java.util.List">
    delete from T_CM_TIMELIST
    where RECORDID in
    <foreach collection="list" item="id" open="(" close=")" separator=",">
      #{id}
    </foreach>
  </delete>
  -->
</mapper>