<?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.yinet.system.mapper.HolidayMapper">

    <resultMap type="com.yinet.system.domain.Holiday" id="HolidayResult">
        <result property="holidayId" column="holiday_id"/>
        <result property="dayTime" column="day_time"/>
        <result property="status" column="status"/>
    </resultMap>

    <sql id="selectHolidayVo">
        select holiday_id, day_time, status from holiday
    </sql>

    <select id="selectHolidayList" parameterType="com.yinet.system.domain.Holiday" resultMap="HolidayResult">
        <include refid="selectHolidayVo"/>
        <where>
            <if test="dayTime != null  and dayTime != ''">and day_time = #{dayTime}</if>
            <if test="status != null ">and status > #{status}</if>
        </where>
    </select>
    <select id="selecAllHoliday" resultMap="HolidayResult">
        <include refid="selectHolidayVo"/>
        where status =1
    </select>
    <insert id="insertHoliday" parameterType="com.yinet.system.domain.Holiday" useGeneratedKeys="true" keyProperty="holidayId">
        insert into holiday
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dayTime != null  and dayTime != ''">day_time,</if>
            <if test="status != null ">status,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dayTime != null  and dayTime != ''">#{dayTime},</if>
            <if test="status != null ">#{status},</if>
        </trim>
    </insert>
    <update id="truncateHoliday">
        truncate table holiday
    </update>
</mapper>