<?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.younike.system.mapper.MerchantServerTimeSectionMapper">

    <resultMap type="ServerTimeSection" id="ServerTimeSectionResult">
        <result property="sectionId"    column="section_id"    />
        <result property="serverId"    column="server_id"    />
        <result property="weeks"    column="weeks"    />
        <result property="hoursFrom"    column="hours_from"    />
        <result property="hoursEnd"    column="hours_end"    />
        <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="column1"    column="column1"    />
        <result property="column2"    column="column2"    />
        <result property="column3"    column="column3"    />
        <result property="isEnable"    column="is_enable"    />
    </resultMap>

    <sql id="selectServerTimeSectionVo">
        select section_id, server_id, weeks, hours_from, hours_end, del_flag, create_by, create_time, update_by, update_time, column1, column2, column3,is_enable from server_time_section
    </sql>

    <select id="selectServerTimeSectionList" parameterType="ServerTimeSection" resultMap="ServerTimeSectionResult">
        <include refid="selectServerTimeSectionVo"/>
        <where>
            <if test="serverId != null  and serverId != ''"> and server_id = #{serverId}</if>
            <if test="weeks != null  and weeks != ''"> and weeks = #{weeks}</if>
            <if test="hoursFrom != null "> and hours_from = #{hoursFrom}</if>
            <if test="hoursEnd != null "> and hours_end = #{hoursEnd}</if>
            <if test="column1 != null  and column1 != ''"> and column1 = #{column1}</if>
            <if test="column2 != null  and column2 != ''"> and column2 = #{column2}</if>
            <if test="column3 != null  and column3 != ''"> and column3 = #{column3}</if>
            <if test="isEnable != null  and isEnable != ''"> and is_enable = #{isEnable}</if>
        </where>
    </select>

    <select id="selectServerTimeSectionBySectionId" parameterType="String" resultMap="ServerTimeSectionResult">
        <include refid="selectServerTimeSectionVo"/>
        where section_id = #{sectionId}
    </select>

    <insert id="insertServerTimeSection" parameterType="ServerTimeSection">
        insert into server_time_section
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="sectionId != null">section_id,</if>
            <if test="serverId != null and serverId != ''">server_id,</if>
            <if test="weeks != null">weeks,</if>
            <if test="hoursFrom != null">hours_from,</if>
            <if test="hoursEnd != null">hours_end,</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="column1 != null">column1,</if>
            <if test="column2 != null">column2,</if>
            <if test="column3 != null">column3,</if>
            <if test="isEnable != null">is_enable,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="sectionId != null">#{sectionId},</if>
            <if test="serverId != null and serverId != ''">#{serverId},</if>
            <if test="weeks != null">#{weeks},</if>
            <if test="hoursFrom != null">#{hoursFrom},</if>
            <if test="hoursEnd != null">#{hoursEnd},</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="column1 != null">#{column1},</if>
            <if test="column2 != null">#{column2},</if>
            <if test="column3 != null">#{column3},</if>
            <if test="isEnable != null">#{isEnable},</if>
        </trim>
    </insert>

    <update id="updateServerTimeSection" parameterType="ServerTimeSection">
        update server_time_section
        <trim prefix="SET" suffixOverrides=",">
            <if test="serverId != null and serverId != ''">server_id = #{serverId},</if>
            <if test="weeks != null">weeks = #{weeks},</if>
            <if test="hoursFrom != null">hours_from = #{hoursFrom},</if>
            <if test="hoursEnd != null">hours_end = #{hoursEnd},</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="column1 != null">column1 = #{column1},</if>
            <if test="column2 != null">column2 = #{column2},</if>
            <if test="column3 != null">column3 = #{column3},</if>
            <if test="isEnable != null">is_enable = #{isEnable},</if>
        </trim>
        where section_id = #{sectionId}
    </update>

    <delete id="deleteServerTimeSectionBySectionId" parameterType="String">
        delete from server_time_section where section_id = #{sectionId}
    </delete>

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