<?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.CourseTableTimeMapper">
    
    <resultMap type="CourseTableTime" id="CourseTableTimeResult">
        <result property="id"    column="id"    />
        <result property="schoolId"    column="school_id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="oneStartTime"    column="one_start_time"    />
        <result property="oneEndTime"    column="one_end_time"    />
        <result property="twoStartTime"    column="two_start_time"    />
        <result property="twoEndTime"    column="two__end_time"    />
        <result property="threeStartTime"    column="three_start_time"    />
        <result property="threeEndTime"    column="three_end_time"    />
        <result property="fourStartTime"    column="four_start_time"    />
        <result property="fourEndTime"    column="four_end_time"    />
        <result property="fiveStartTime"    column="five_start_time"    />
        <result property="fiveEndTime"    column="five_end_time"    />
        <result property="sixStartTime"    column="six_start_time"    />
        <result property="sixEndTime"    column="six_end_time"    />
        <result property="sevenStartTime"    column="seven_start_time"    />
        <result property="sevenEndTime"    column="seven_end_time"    />
        <result property="eightStartTime"    column="eight_start_time"    />
        <result property="eightEndTime"    column="eight_end_time"    />
        <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="remark"    column="remark"    />
    </resultMap>

    <sql id="selectCourseTableTimeVo">
        select id, school_id, school_name, one_start_time, one_end_time, two_start_time, two__end_time, three_start_time, three_end_time, four_start_time, four_end_time, five_start_time, five_end_time, six_start_time, six_end_time, seven_start_time, seven_end_time, eight_start_time, eight_end_time, create_by, create_time, update_by, update_time, remark from course_table_time
    </sql>

    <select id="selectCourseTableTimeList" parameterType="CourseTableTime" resultMap="CourseTableTimeResult">
        <include refid="selectCourseTableTimeVo"/>
        <where>
            <if test="schoolId != null  and schoolId != 0"> and school_id = #{schoolId}</if>
            <if test="schoolName != null  and schoolName != ''"> and school_name like concat('%', #{schoolName}, '%')</if>
            <if test="oneStartTime != null  and oneStartTime != ''"> and one_start_time = #{oneStartTime}</if>
            <if test="oneEndTime != null  and oneEndTime != ''"> and one_end_time = #{oneEndTime}</if>
            <if test="twoStartTime != null  and twoStartTime != ''"> and two_start_time = #{twoStartTime}</if>
            <if test="twoEndTime != null  and twoEndTime != ''"> and two__end_time = #{twoEndTime}</if>
            <if test="threeStartTime != null  and threeStartTime != ''"> and three_start_time = #{threeStartTime}</if>
            <if test="threeEndTime != null  and threeEndTime != ''"> and three_end_time = #{threeEndTime}</if>
            <if test="fourStartTime != null  and fourStartTime != ''"> and four_start_time = #{fourStartTime}</if>
            <if test="fourEndTime != null  and fourEndTime != ''"> and four_end_time = #{fourEndTime}</if>
            <if test="fiveStartTime != null  and fiveStartTime != ''"> and five_start_time = #{fiveStartTime}</if>
            <if test="fiveEndTime != null  and fiveEndTime != ''"> and five_end_time = #{fiveEndTime}</if>
            <if test="sixStartTime != null  and sixStartTime != ''"> and six_start_time = #{sixStartTime}</if>
            <if test="sixEndTime != null  and sixEndTime != ''"> and six_end_time = #{sixEndTime}</if>
            <if test="sevenStartTime != null  and sevenStartTime != ''"> and seven_start_time = #{sevenStartTime}</if>
            <if test="sevenEndTime != null  and sevenEndTime != ''"> and seven_end_time = #{sevenEndTime}</if>
            <if test="eightStartTime != null  and eightStartTime != ''"> and eight_start_time = #{eightStartTime}</if>
            <if test="eightEndTime != null  and eightEndTime != ''"> and eight_end_time = #{eightEndTime}</if>
        </where>
    </select>
    
    <select id="selectCourseTableTimeById" parameterType="Long" resultMap="CourseTableTimeResult">
        <include refid="selectCourseTableTimeVo"/>
        where id = #{id}
    </select>
    <select id="selectCourseTableTimeBySchoolId" resultMap="CourseTableTimeResult">
        <include refid="selectCourseTableTimeVo"/>
        where school_id = #{schoolId}
    </select>

    <insert id="insertCourseTableTime" parameterType="CourseTableTime" useGeneratedKeys="true" keyProperty="id">
        insert into course_table_time
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="schoolId != null">school_id,</if>
            <if test="schoolName != null">school_name,</if>
            <if test="oneStartTime != null">one_start_time,</if>
            <if test="oneEndTime != null">one_end_time,</if>
            <if test="twoStartTime != null">two_start_time,</if>
            <if test="twoEndTime != null">two__end_time,</if>
            <if test="threeStartTime != null">three_start_time,</if>
            <if test="threeEndTime != null">three_end_time,</if>
            <if test="fourStartTime != null">four_start_time,</if>
            <if test="fourEndTime != null">four_end_time,</if>
            <if test="fiveStartTime != null">five_start_time,</if>
            <if test="fiveEndTime != null">five_end_time,</if>
            <if test="sixStartTime != null">six_start_time,</if>
            <if test="sixEndTime != null">six_end_time,</if>
            <if test="sevenStartTime != null">seven_start_time,</if>
            <if test="sevenEndTime != null">seven_end_time,</if>
            <if test="eightStartTime != null">eight_start_time,</if>
            <if test="eightEndTime != null">eight_end_time,</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="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="schoolId != null">#{schoolId},</if>
            <if test="schoolName != null">#{schoolName},</if>
            <if test="oneStartTime != null">#{oneStartTime},</if>
            <if test="oneEndTime != null">#{oneEndTime},</if>
            <if test="twoStartTime != null">#{twoStartTime},</if>
            <if test="twoEndTime != null">#{twoEndTime},</if>
            <if test="threeStartTime != null">#{threeStartTime},</if>
            <if test="threeEndTime != null">#{threeEndTime},</if>
            <if test="fourStartTime != null">#{fourStartTime},</if>
            <if test="fourEndTime != null">#{fourEndTime},</if>
            <if test="fiveStartTime != null">#{fiveStartTime},</if>
            <if test="fiveEndTime != null">#{fiveEndTime},</if>
            <if test="sixStartTime != null">#{sixStartTime},</if>
            <if test="sixEndTime != null">#{sixEndTime},</if>
            <if test="sevenStartTime != null">#{sevenStartTime},</if>
            <if test="sevenEndTime != null">#{sevenEndTime},</if>
            <if test="eightStartTime != null">#{eightStartTime},</if>
            <if test="eightEndTime != null">#{eightEndTime},</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="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateCourseTableTime" parameterType="CourseTableTime">
        update course_table_time
        <trim prefix="SET" suffixOverrides=",">
            <if test="schoolId != null">school_id = #{schoolId},</if>
            <if test="schoolName != null">school_name = #{schoolName},</if>
            <if test="oneStartTime != null">one_start_time = #{oneStartTime},</if>
            <if test="oneEndTime != null">one_end_time = #{oneEndTime},</if>
            <if test="twoStartTime != null">two_start_time = #{twoStartTime},</if>
            <if test="twoEndTime != null">two__end_time = #{twoEndTime},</if>
            <if test="threeStartTime != null">three_start_time = #{threeStartTime},</if>
            <if test="threeEndTime != null">three_end_time = #{threeEndTime},</if>
            <if test="fourStartTime != null">four_start_time = #{fourStartTime},</if>
            <if test="fourEndTime != null">four_end_time = #{fourEndTime},</if>
            <if test="fiveStartTime != null">five_start_time = #{fiveStartTime},</if>
            <if test="fiveEndTime != null">five_end_time = #{fiveEndTime},</if>
            <if test="sixStartTime != null">six_start_time = #{sixStartTime},</if>
            <if test="sixEndTime != null">six_end_time = #{sixEndTime},</if>
            <if test="sevenStartTime != null">seven_start_time = #{sevenStartTime},</if>
            <if test="sevenEndTime != null">seven_end_time = #{sevenEndTime},</if>
            <if test="eightStartTime != null">eight_start_time = #{eightStartTime},</if>
            <if test="eightEndTime != null">eight_end_time = #{eightEndTime},</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="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteCourseTableTimeById" parameterType="Long">
        delete from course_table_time where id = #{id}
    </delete>

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