<?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.SysTeacherThesisMapper">
    
    <resultMap type="SysTeacherThesis" id="SysTeacherThesisResult">
        <result property="thesisId"    column="thesis_id"    />
        <result property="teacherId"    column="teacher_id"    />
        <result property="name"    column="name"    />
        <result property="title"    column="title"    />
        <result property="issue"    column="issue"    />
        <result property="publication"    column="publication"    />
        <result property="level"    column="level"    />
        <result property="year"    column="year"    />
        <result property="evidence"    column="evidence"    />
        <result property="checkStatus"    column="check_status"    />
        <result property="checkPerson"    column="check_person"    />
        <result property="college"    column="college"    />
        <result property="returnReason"    column="returnReason"    />
        <result property="submitYear"    column="submitYear"    />
    </resultMap>

    <sql id="selectSysTeacherThesisVo">
        select thesis_id, teacher_id, name, title, issue, publication, level, year, evidence, check_status, check_person, college, returnReason, submitYear from sys_teacher_thesis
    </sql>

    <select id="selectSysTeacherThesisList" parameterType="SysTeacherThesis" resultMap="SysTeacherThesisResult">
        <include refid="selectSysTeacherThesisVo"/>
        <where>  
            <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="title != null  and title != ''"> and title = #{title}</if>
            <if test="issue != null  and issue != ''"> and issue = #{issue}</if>
            <if test="publication != null  and publication != ''"> and publication = #{publication}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="evidence != null  and evidence != ''"> and evidence = #{evidence}</if>
            <if test="checkStatus != null  and checkStatus != ''"> and check_status = #{checkStatus}</if>
            <if test="checkPerson != null  and checkPerson != ''"> and check_person = #{checkPerson}</if>
            <if test="college != null  and college != ''"> and college = #{college}</if>
            <if test="returnReason != null  and returnReason != ''"> and returnReason = #{returnReason}</if>
            <if test="submitYear != null  and submitYear != ''"> and submitYear = #{submitYear}</if>
        </where>
    </select>
    
    <select id="selectSysTeacherThesisByThesisId" parameterType="Long" resultMap="SysTeacherThesisResult">
        <include refid="selectSysTeacherThesisVo"/>
        where thesis_id = #{thesisId}
    </select>
        
    <insert id="insertSysTeacherThesis" parameterType="SysTeacherThesis" useGeneratedKeys="true" keyProperty="thesisId">
        insert into sys_teacher_thesis
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">teacher_id,</if>
            <if test="name != null">name,</if>
            <if test="title != null">title,</if>
            <if test="issue != null">issue,</if>
            <if test="publication != null">publication,</if>
            <if test="level != null">level,</if>
            <if test="year != null">year,</if>
            <if test="evidence != null">evidence,</if>
            <if test="checkStatus != null">check_status,</if>
            <if test="checkPerson != null">check_person,</if>
            <if test="college != null">college,</if>
            <if test="returnReason != null">returnReason,</if>
            <if test="submitYear != null">submitYear,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">#{teacherId},</if>
            <if test="name != null">#{name},</if>
            <if test="title != null">#{title},</if>
            <if test="issue != null">#{issue},</if>
            <if test="publication != null">#{publication},</if>
            <if test="level != null">#{level},</if>
            <if test="year != null">#{year},</if>
            <if test="evidence != null">#{evidence},</if>
            <if test="checkStatus != null">#{checkStatus},</if>
            <if test="checkPerson != null">#{checkPerson},</if>
            <if test="college != null">#{college},</if>
            <if test="returnReason != null">#{returnReason},</if>
            <if test="submitYear != null">#{submitYear},</if>
         </trim>
    </insert>

    <update id="updateSysTeacherThesis" parameterType="SysTeacherThesis">
        update sys_teacher_thesis
        <trim prefix="SET" suffixOverrides=",">
            <if test="teacherId != null">teacher_id = #{teacherId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="title != null">title = #{title},</if>
            <if test="issue != null">issue = #{issue},</if>
            <if test="publication != null">publication = #{publication},</if>
            <if test="level != null">level = #{level},</if>
            <if test="year != null">year = #{year},</if>
            <if test="evidence != null">evidence = #{evidence},</if>
            <if test="checkStatus != null">check_status = #{checkStatus},</if>
            <if test="checkPerson != null">check_person = #{checkPerson},</if>
            <if test="college != null">college = #{college},</if>
            <if test="returnReason != null">returnReason = #{returnReason},</if>
            <if test="submitYear != null">submitYear = #{submitYear},</if>
        </trim>
        where thesis_id = #{thesisId}
    </update>

    <delete id="deleteSysTeacherThesisByThesisId" parameterType="Long">
        delete from sys_teacher_thesis where thesis_id = #{thesisId}
    </delete>

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