<?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.dcsoft.job.mapper.KqHolidayMapper">

    <resultMap type="KqHoliday" id="KqHolidayResult">
        <result property="holidayId"    column="holiday_id"    />
        <result property="timeStamp"    column="time_stamp"    />
        <result property="time"    column="time"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="status"    column="status"    />
    </resultMap>

    <sql id="selectKqHolidayVo">
        select holiday_id, time_stamp, time, del_flag, create_by, create_time, update_by, update_time,status from kq_holiday
    </sql>

    <select id="selectKqHolidayList" parameterType="KqHoliday" resultMap="KqHolidayResult">
        <include refid="selectKqHolidayVo"/>
        <where>
            <if test="timeStamp != null "> and time_stamp = #{timeStamp}</if>
            <if test="time != null "> and time = #{time}</if>
            <if test="startTimeStep != null "> and time_stamp > #{startTimeStep}</if>
            <if test="endTimeStep != null "> and time_stamp &lt; #{endTimeStep}</if>
        </where>
    </select>

    <select id="selectKqHolidayByHolidayId" parameterType="Long" resultMap="KqHolidayResult">
        <include refid="selectKqHolidayVo"/>
        where holiday_id = #{holidayId}
    </select>

    <insert id="insertKqHoliday" parameterType="KqHoliday" useGeneratedKeys="true" keyProperty="holidayId">
        insert into kq_holiday
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="timeStamp != null">time_stamp,</if>
            <if test="time != null">time,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="status != null">status,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="timeStamp != null">#{timeStamp},</if>
            <if test="time != null">#{time},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="status != null">#{status},</if>

        </trim>
    </insert>

    <update id="updateKqHoliday" parameterType="KqHoliday">
        update kq_holiday
        <trim prefix="SET" suffixOverrides=",">
            <if test="timeStamp != null">time_stamp = #{timeStamp},</if>
            <if test="time != null">time = #{time},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="status != null">status = #{status},</if>

        </trim>
        where holiday_id = #{holidayId}
    </update>

    <delete id="deleteKqHolidayByHolidayId" parameterType="Long">
        delete from kq_holiday where holiday_id = #{holidayId}
    </delete>

    <delete id="deleteKqHolidayByHolidayIds" parameterType="String">
        delete from kq_holiday where holiday_id in
        <foreach item="holidayId" collection="array" open="(" separator="," close=")">
            #{holidayId}
        </foreach>
    </delete>

    <select id="selectKqHolidayByHolidayTimeStamp" parameterType="Long" resultMap="KqHolidayResult">
        <include refid="selectKqHolidayVo"/>
        where time_stamp = #{timeStamp}
    </select>

    <delete id="deleteKqHolidayByHolidayTimeStamp" parameterType="Long">
        delete from kq_holiday where time_stamp = #{timeStamp}
    </delete>

</mapper>
