<?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.ruoyi.system.mapper.SysHolidayMapper">
    
    <resultMap type="SysHoliday" id="SysHolidayResult">
        <result property="id"    column="id"    />
        <result property="year"    column="year"    />
        <result property="day"    column="day"    />
        <result property="type"    column="type"    />
    </resultMap>

    <sql id="selectSysHolidayVo">
        select id, year, day, type from sys_holiday
    </sql>

    <select id="selectSysHolidayList" parameterType="SysHoliday" resultMap="SysHolidayResult">
        <include refid="selectSysHolidayVo"/>
        <where>  
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="day != null  and day != ''"> and day = #{day}</if>
            <if test="type != null  and type != ''"> and type = #{type}</if>
        </where>
    </select>
    
    <select id="selectSysHolidayById" parameterType="Long" resultMap="SysHolidayResult">
        <include refid="selectSysHolidayVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysHoliday" parameterType="SysHoliday">
        insert into sys_holiday
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="year != null">year,</if>
            <if test="day != null">day,</if>
            <if test="type != null">type,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="year != null">#{year},</if>
            <if test="day != null">#{day},</if>
            <if test="type != null">#{type},</if>
         </trim>
    </insert>

    <update id="updateSysHoliday" parameterType="SysHoliday">
        update sys_holiday
        <trim prefix="SET" suffixOverrides=",">
            <if test="year != null">year = #{year},</if>
            <if test="day != null">day = #{day},</if>
            <if test="type != null">type = #{type},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysHolidayById" parameterType="Long">
        delete from sys_holiday where id = #{id}
    </delete>

    <delete id="deleteSysHolidayByIds" parameterType="String">
        delete from sys_holiday where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>