<?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.xunmei.system.mapper.SysWorkTimeSetDayofweekMapper">

    <resultMap type="com.xunmei.system.domain.SysWorkTimeSetDayofweek" id="SysWorkTimeSetDayofweekResult">
                <result property="id" column="id"/>
                <result property="workTimeSetId" column="work_time_set_id"/>
                <result property="isWorkday" column="is_workday"/>
                <result property="dayOfWeek" column="day_of_week"/>
                <result property="workTime" column="work_time"/>
                <result property="openTime" column="open_time"/>
                <result property="noonbreakStart" column="noonbreak_start"/>
                <result property="noonbreakEnd" column="noonbreak_end"/>
                <result property="closeTime" column="close_time"/>
                <result property="workOffTime" column="work_off_time"/>
    </resultMap>

    <sql id="selectSysWorkTimeSetDayofweekVo">
        select id, work_time_set_id, is_workday, day_of_week, work_time, open_time, noonbreak_start, noonbreak_end, close_time, work_off_time
        from sys_work_time_set_dayofweek
    </sql>

    <select id="selectSysWorkTimeSetDayofweekList" parameterType="com.xunmei.system.domain.SysWorkTimeSetDayofweek"
            resultMap="SysWorkTimeSetDayofweekResult">
        <include refid="selectSysWorkTimeSetDayofweekVo"/>
        <where>
                        <if test="workTimeSetId != null ">
                            and work_time_set_id = #{workTimeSetId}
                        </if>
                        <if test="isWorkday != null ">
                            and is_workday = #{isWorkday}
                        </if>
                        <if test="dayOfWeek != null ">
                            and day_of_week = #{dayOfWeek}
                        </if>
                        <if test="workTime != null  and workTime != ''">
                            and work_time = #{workTime}
                        </if>
                        <if test="openTime != null  and openTime != ''">
                            and open_time = #{openTime}
                        </if>
                        <if test="noonbreakStart != null  and noonbreakStart != ''">
                            and noonbreak_start = #{noonbreakStart}
                        </if>
                        <if test="noonbreakEnd != null  and noonbreakEnd != ''">
                            and noonbreak_end = #{noonbreakEnd}
                        </if>
                        <if test="closeTime != null  and closeTime != ''">
                            and close_time = #{closeTime}
                        </if>
                        <if test="workOffTime != null  and workOffTime != ''">
                            and work_off_time = #{workOffTime}
                        </if>
        </where>
    </select>

    <select id="selectSysWorkTimeSetDayofweekById" parameterType="Long"
            resultMap="SysWorkTimeSetDayofweekResult">
            <include refid="selectSysWorkTimeSetDayofweekVo"/>
            where id = #{id}
    </select>
    <select id="findByWorkTimeSetIdIn" resultType="com.xunmei.system.domain.SysWorkTimeSetDayofweek">
        select * from sys_work_time_set_dayofweek where work_time_set_id in
        <foreach item="ids" collection="list" open="(" separator="," close=")">
            #{ids}
        </foreach>

    </select>

    <insert id="insertSysWorkTimeSetDayofweek" parameterType="com.xunmei.system.domain.SysWorkTimeSetDayofweek"            useGeneratedKeys="true" keyProperty="id">
        insert into sys_work_time_set_dayofweek
        <trim prefix="(" suffix=")" suffixOverrides=",">
                    <if test="workTimeSetId != null">work_time_set_id,
                    </if>
                    <if test="isWorkday != null">is_workday,
                    </if>
                    <if test="dayOfWeek != null">day_of_week,
                    </if>
                    <if test="workTime != null">work_time,
                    </if>
                    <if test="openTime != null">open_time,
                    </if>
                    <if test="noonbreakStart != null">noonbreak_start,
                    </if>
                    <if test="noonbreakEnd != null">noonbreak_end,
                    </if>
                    <if test="closeTime != null">close_time,
                    </if>
                    <if test="workOffTime != null">work_off_time,
                    </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                    <if test="workTimeSetId != null">#{workTimeSetId},
                    </if>
                    <if test="isWorkday != null">#{isWorkday},
                    </if>
                    <if test="dayOfWeek != null">#{dayOfWeek},
                    </if>
                    <if test="workTime != null">#{workTime},
                    </if>
                    <if test="openTime != null">#{openTime},
                    </if>
                    <if test="noonbreakStart != null">#{noonbreakStart},
                    </if>
                    <if test="noonbreakEnd != null">#{noonbreakEnd},
                    </if>
                    <if test="closeTime != null">#{closeTime},
                    </if>
                    <if test="workOffTime != null">#{workOffTime},
                    </if>
        </trim>
    </insert>

    <update id="updateSysWorkTimeSetDayofweek" parameterType="com.xunmei.system.domain.SysWorkTimeSetDayofweek">
        update sys_work_time_set_dayofweek
        <trim prefix="SET" suffixOverrides=",">
                    <if test="workTimeSetId != null">work_time_set_id =
                        #{workTimeSetId},
                    </if>
                    <if test="isWorkday != null">is_workday =
                        #{isWorkday},
                    </if>
                    <if test="dayOfWeek != null">day_of_week =
                        #{dayOfWeek},
                    </if>
                    <if test="workTime != null">work_time =
                        #{workTime},
                    </if>
                    <if test="openTime != null">open_time =
                        #{openTime},
                    </if>
                    <if test="noonbreakStart != null">noonbreak_start =
                        #{noonbreakStart},
                    </if>
                    <if test="noonbreakEnd != null">noonbreak_end =
                        #{noonbreakEnd},
                    </if>
                    <if test="closeTime != null">close_time =
                        #{closeTime},
                    </if>
                    <if test="workOffTime != null">work_off_time =
                        #{workOffTime},
                    </if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysWorkTimeSetDayofweekById" parameterType="Long">
        delete
        from sys_work_time_set_dayofweek where id = #{id}
    </delete>

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