<?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.SysTeacherStudyMapper">
    
    <resultMap type="SysTeacherStudy" id="SysTeacherStudyResult">
        <result property="studyId"    column="study_id"    />
        <result property="teacherId"    column="teacher_id"    />
        <result property="educated"    column="educated"    />
        <result property="study"    column="study"    />
        <result property="graduationTime"    column="graduationTime"    />
        <result property="education"    column="education"    />
        <result property="educationTime"    column="educationTime"    />
    </resultMap>

    <sql id="selectSysTeacherStudyVo">
        select study_id, teacher_id, educated, study, graduationTime, education, educationTime from sys_teacher_study
    </sql>

    <select id="selectSysTeacherStudyList" parameterType="SysTeacherStudy" resultMap="SysTeacherStudyResult">
        <include refid="selectSysTeacherStudyVo"/>
        <where>  
            <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
            <if test="educated != null  and educated != ''"> and educated = #{educated}</if>
            <if test="study != null  and study != ''"> and study = #{study}</if>
            <if test="graduationTime != null  and graduationTime != ''"> and graduationTime = #{graduationTime}</if>
            <if test="education != null  and education != ''"> and education = #{education}</if>
            <if test="educationTime != null  and educationTime != ''"> and educationTime = #{educationTime}</if>
        </where>
    </select>
    
    <select id="selectSysTeacherStudyByStudyId" parameterType="Long" resultMap="SysTeacherStudyResult">
        <include refid="selectSysTeacherStudyVo"/>
        where study_id = #{studyId}
    </select>
        
    <insert id="insertSysTeacherStudy" parameterType="SysTeacherStudy" useGeneratedKeys="true" keyProperty="studyId">
        insert into sys_teacher_study
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">teacher_id,</if>
            <if test="educated != null">educated,</if>
            <if test="study != null">study,</if>
            <if test="graduationTime != null">graduationTime,</if>
            <if test="education != null">education,</if>
            <if test="educationTime != null">educationTime,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">#{teacherId},</if>
            <if test="educated != null">#{educated},</if>
            <if test="study != null">#{study},</if>
            <if test="graduationTime != null">#{graduationTime},</if>
            <if test="education != null">#{education},</if>
            <if test="educationTime != null">#{educationTime},</if>
         </trim>
    </insert>

    <update id="updateSysTeacherStudy" parameterType="SysTeacherStudy">
        update sys_teacher_study
        <trim prefix="SET" suffixOverrides=",">
            <if test="teacherId != null">teacher_id = #{teacherId},</if>
            <if test="educated != null">educated = #{educated},</if>
            <if test="study != null">study = #{study},</if>
            <if test="graduationTime != null">graduationTime = #{graduationTime},</if>
            <if test="education != null">education = #{education},</if>
            <if test="educationTime != null">educationTime = #{educationTime},</if>
        </trim>
        where study_id = #{studyId}
    </update>

    <delete id="deleteSysTeacherStudyByStudyId" parameterType="Long">
        delete from sys_teacher_study where study_id = #{studyId}
    </delete>

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