<?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.persagy.calendar.mapper.HolidayMapper">
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        ID,WORK_DATE,WORKDAY_CODE,WORKDAY_NAME,WEEK_CODE,WEEK_NAME,WEEKEND_CODE,WEEKEND_NAME,HOLIDAY_CODE,HOLIDAY_NAME,
        CREATOR,CREATE_TIME,MODIFIER, MODIFIED_TIME,VALID
    </sql>

    <resultMap id="BaseResultMap" type="com.persagy.calendar.pojo.dto.Holiday" >
        <id property="id" column="ID"/>
        <result property="workDate" column="WORK_DATE"/>
        <result property="workdayCode" column="WORKDAY_CODE"/>
        <result property="workdayName" column="WORKDAY_NAME"/>
        <result property="weekCode" column="WEEK_CODE"/>
        <result property="weekName" column="WEEK_NAME"/>
        <result property="weekendCode" column="WEEKEND_CODE"/>
        <result property="weekendName" column="WEEKEND_NAME"/>
        <result property="holidayCode" column="HOLIDAY_CODE"/>
        <result property="holidayName" column="HOLIDAY_NAME"/>
        <result property="creator" column="CREATOR"/>
        <result property="createTime" column="CREATE_TIME"/>
        <result property="modifier" column="MODIFIER"/>
        <result property="modifiedTime" column="MODIFIED_TIME"/>
        <result property="valid" column="VALID"/>
    </resultMap>

    <insert id="insertBatch" parameterType="java.util.List">
        INSERT INTO t_holiday(
            WORK_DATE,WORKDAY_CODE,WORKDAY_NAME,WEEK_CODE,WEEK_NAME,WEEKEND_CODE,WEEKEND_NAME,HOLIDAY_CODE,HOLIDAY_NAME,
            CREATOR,CREATE_TIME,MODIFIER,MODIFIED_TIME,VALID)
        VALUES
        <foreach collection="list" close="" index="index" item="item" open="" separator=",">
            (#{item.workDate},#{item.workdayCode},#{item.workdayName},#{item.weekCode},#{item.weekName},
             #{item.weekendCode},#{item.weekendName},#{item.holidayCode},#{item.holidayName},#{item.creator},
            #{item.createTime},#{item.modifier},#{item.modifiedTime},#{item.valid})
        </foreach>
    </insert>

    <select id="getHolidayList" parameterType="com.persagy.calendar.pojo.vo.HolidayQueryVO" resultMap="BaseResultMap">
        SELECT
        <include refid="Base_Column_List"/>
        FROM t_holiday
        WHERE 1=1
        <if test="(startTime != null and startTime != '') and (endTime != null and endTime != '')">
            AND WORK_DATE BETWEEN #{startTime} AND #{endTime}
        </if>
    </select>

</mapper>
