<?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.srs.teacher.mapper.SysTeacherTakeclassMapper">
    
    <resultMap type="SysTeacherTakeclass" id="SysTeacherTakeclassResult">
        <result property="takeclassId"    column="takeclass_id"    />
        <result property="teacherId"    column="teacher_id"    />
        <result property="college"    column="college"    />
        <result property="grade"    column="grade"    />
        <result property="classteam"    column="classteam"    />
        <result property="number"    column="number"    />
    </resultMap>

    <sql id="selectSysTeacherTakeclassVo">
        select takeclass_id, teacher_id, college, grade, classteam, number from sys_teacher_takeclass
    </sql>

    <select id="selectSysTeacherTakeclassList" parameterType="SysTeacherTakeclass" resultMap="SysTeacherTakeclassResult">
        <include refid="selectSysTeacherTakeclassVo"/>
        <where>  
            <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
            <if test="college != null  and college != ''"> and college = #{college}</if>
            <if test="grade != null  and grade != ''"> and grade = #{grade}</if>
            <if test="classteam != null  and classteam != ''"> and classteam = #{classteam}</if>
            <if test="number != null "> and number = #{number}</if>
        </where>
    </select>
    
    <select id="selectSysTeacherTakeclassByTakeclassId" parameterType="Long" resultMap="SysTeacherTakeclassResult">
        <include refid="selectSysTeacherTakeclassVo"/>
        where takeclass_id = #{takeclassId}
    </select>
        
    <insert id="insertSysTeacherTakeclass" parameterType="SysTeacherTakeclass" useGeneratedKeys="true" keyProperty="takeclassId">
        insert into sys_teacher_takeclass
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">teacher_id,</if>
            <if test="college != null">college,</if>
            <if test="grade != null">grade,</if>
            <if test="classteam != null">classteam,</if>
            <if test="number != null">number,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">#{teacherId},</if>
            <if test="college != null">#{college},</if>
            <if test="grade != null">#{grade},</if>
            <if test="classteam != null">#{classteam},</if>
            <if test="number != null">#{number},</if>
         </trim>
    </insert>

    <update id="updateSysTeacherTakeclass" parameterType="SysTeacherTakeclass">
        update sys_teacher_takeclass
        <trim prefix="SET" suffixOverrides=",">
            <if test="teacherId != null">teacher_id = #{teacherId},</if>
            <if test="college != null">college = #{college},</if>
            <if test="grade != null">grade = #{grade},</if>
            <if test="classteam != null">classteam = #{classteam},</if>
            <if test="number != null">number = #{number},</if>
        </trim>
        where takeclass_id = #{takeclassId}
    </update>

    <delete id="deleteSysTeacherTakeclassByTakeclassId" parameterType="Long">
        delete from sys_teacher_takeclass where takeclass_id = #{takeclassId}
    </delete>

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