<?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.CourseTableMapper">
    
    <resultMap type="CourseTable" id="CourseTableResult">
        <result property="id"    column="id"    />
        <result property="schoolId"    column="school_id"    />
        <result property="schoolName"    column="school_name"    />
        <result property="classId"    column="class_id"    />
        <result property="className"    column="class_name"    />
        <result property="week"    column="week"    />
        <result property="oneClass"    column="one_class"    />
        <result property="oneTeacher"    column="one_teacher"    />
        <result property="twoClass"    column="two_class"    />
        <result property="twoTeacher"    column="two_teacher"    />
        <result property="threeClass"    column="three_class"    />
        <result property="threeTeacher"    column="three_teacher"    />
        <result property="fourClass"    column="four_class"    />
        <result property="fourTeacher"    column="four_teacher"    />
        <result property="fiveClass"    column="five_class"    />
        <result property="fiveTeacher"    column="five_teacher"    />
        <result property="sixClass"    column="six_class"    />
        <result property="sixTeacher"    column="six_teacher"    />
        <result property="sevenClass"    column="seven_class"    />
        <result property="sevenTeacher"    column="seven_teacher"    />
        <result property="eightClass"    column="eight_class"    />
        <result property="eightTeacher"    column="eight_teacher"    />
        <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="selectCourseTableVo">
        select id, school_id, school_name, class_id, class_name, week, one_class, one_teacher, two_class, two_teacher, three_class, three_teacher, four_class, four_teacher, five_class, five_teacher, six_class, six_teacher, seven_class, seven_teacher, eight_class, eight_teacher, create_by, create_time, update_by, update_time, remark from course_table
    </sql>

    <select id="selectCourseTableList" parameterType="CourseTable" resultMap="CourseTableResult">
        <include refid="selectCourseTableVo"/>
        <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="classId != null  and classId != 0"> and class_id = #{classId}</if>
            <if test="className != null  and className != ''"> and class_name like concat('%', #{className}, '%')</if>
            <if test="week != null  and week != ''"> and week = #{week}</if>
            <if test="oneClass != null  and oneClass != ''"> and one_class = #{oneClass}</if>
            <if test="oneTeacher != null  and oneTeacher != ''"> and one_teacher = #{oneTeacher}</if>
            <if test="twoClass != null  and twoClass != ''"> and two_class = #{twoClass}</if>
            <if test="twoTeacher != null  and twoTeacher != ''"> and two_teacher = #{twoTeacher}</if>
            <if test="threeClass != null  and threeClass != ''"> and three_class = #{threeClass}</if>
            <if test="threeTeacher != null  and threeTeacher != ''"> and three_teacher = #{threeTeacher}</if>
            <if test="fourClass != null  and fourClass != ''"> and four_class = #{fourClass}</if>
            <if test="fourTeacher != null  and fourTeacher != ''"> and four_teacher = #{fourTeacher}</if>
            <if test="fiveClass != null  and fiveClass != ''"> and five_class = #{fiveClass}</if>
            <if test="fiveTeacher != null  and fiveTeacher != ''"> and five_teacher = #{fiveTeacher}</if>
            <if test="sixClass != null  and sixClass != ''"> and six_class = #{sixClass}</if>
            <if test="sixTeacher != null  and sixTeacher != ''"> and six_teacher = #{sixTeacher}</if>
            <if test="sevenClass != null  and sevenClass != ''"> and seven_class = #{sevenClass}</if>
            <if test="sevenTeacher != null  and sevenTeacher != ''"> and seven_teacher = #{sevenTeacher}</if>
            <if test="eightClass != null  and eightClass != ''"> and eight_class = #{eightClass}</if>
            <if test="eightTeacher != null  and eightTeacher != ''"> and eight_teacher = #{eightTeacher}</if>
        </where>
    </select>
    
    <select id="selectCourseTableById" parameterType="Long" resultMap="CourseTableResult">
        <include refid="selectCourseTableVo"/>
        where id = #{id}
    </select>
    <select id="selectCourseTableByClassIdAndWeek" resultMap="CourseTableResult">
        <include refid="selectCourseTableVo"/>
        where class_id = #{classId} and week = #{week}
    </select>

    <insert id="insertCourseTable" parameterType="CourseTable" useGeneratedKeys="true" keyProperty="id">
        insert into course_table
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="schoolId != null">school_id,</if>
            <if test="schoolName != null">school_name,</if>
            <if test="classId != null">class_id,</if>
            <if test="className != null">class_name,</if>
            <if test="week != null">week,</if>
            <if test="oneClass != null">one_class,</if>
            <if test="oneTeacher != null">one_teacher,</if>
            <if test="twoClass != null">two_class,</if>
            <if test="twoTeacher != null">two_teacher,</if>
            <if test="threeClass != null">three_class,</if>
            <if test="threeTeacher != null">three_teacher,</if>
            <if test="fourClass != null">four_class,</if>
            <if test="fourTeacher != null">four_teacher,</if>
            <if test="fiveClass != null">five_class,</if>
            <if test="fiveTeacher != null">five_teacher,</if>
            <if test="sixClass != null">six_class,</if>
            <if test="sixTeacher != null">six_teacher,</if>
            <if test="sevenClass != null">seven_class,</if>
            <if test="sevenTeacher != null">seven_teacher,</if>
            <if test="eightClass != null">eight_class,</if>
            <if test="eightTeacher != null">eight_teacher,</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="classId != null">#{classId},</if>
            <if test="className != null">#{className},</if>
            <if test="week != null">#{week},</if>
            <if test="oneClass != null">#{oneClass},</if>
            <if test="oneTeacher != null">#{oneTeacher},</if>
            <if test="twoClass != null">#{twoClass},</if>
            <if test="twoTeacher != null">#{twoTeacher},</if>
            <if test="threeClass != null">#{threeClass},</if>
            <if test="threeTeacher != null">#{threeTeacher},</if>
            <if test="fourClass != null">#{fourClass},</if>
            <if test="fourTeacher != null">#{fourTeacher},</if>
            <if test="fiveClass != null">#{fiveClass},</if>
            <if test="fiveTeacher != null">#{fiveTeacher},</if>
            <if test="sixClass != null">#{sixClass},</if>
            <if test="sixTeacher != null">#{sixTeacher},</if>
            <if test="sevenClass != null">#{sevenClass},</if>
            <if test="sevenTeacher != null">#{sevenTeacher},</if>
            <if test="eightClass != null">#{eightClass},</if>
            <if test="eightTeacher != null">#{eightTeacher},</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="updateCourseTable" parameterType="CourseTable">
        update course_table
        <trim prefix="SET" suffixOverrides=",">
            <if test="schoolId != null">school_id = #{schoolId},</if>
            <if test="schoolName != null">school_name = #{schoolName},</if>
            <if test="classId != null">class_id = #{classId},</if>
            <if test="className != null">class_name = #{className},</if>
            <if test="week != null">week = #{week},</if>
            <if test="oneClass != null">one_class = #{oneClass},</if>
            <if test="oneTeacher != null">one_teacher = #{oneTeacher},</if>
            <if test="twoClass != null">two_class = #{twoClass},</if>
            <if test="twoTeacher != null">two_teacher = #{twoTeacher},</if>
            <if test="threeClass != null">three_class = #{threeClass},</if>
            <if test="threeTeacher != null">three_teacher = #{threeTeacher},</if>
            <if test="fourClass != null">four_class = #{fourClass},</if>
            <if test="fourTeacher != null">four_teacher = #{fourTeacher},</if>
            <if test="fiveClass != null">five_class = #{fiveClass},</if>
            <if test="fiveTeacher != null">five_teacher = #{fiveTeacher},</if>
            <if test="sixClass != null">six_class = #{sixClass},</if>
            <if test="sixTeacher != null">six_teacher = #{sixTeacher},</if>
            <if test="sevenClass != null">seven_class = #{sevenClass},</if>
            <if test="sevenTeacher != null">seven_teacher = #{sevenTeacher},</if>
            <if test="eightClass != null">eight_class = #{eightClass},</if>
            <if test="eightTeacher != null">eight_teacher = #{eightTeacher},</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="deleteCourseTableById" parameterType="Long">
        delete from course_table where id = #{id}
    </delete>

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