<?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.SysTeacherHonorMapper">
    
    <resultMap type="SysTeacherHonor" id="SysTeacherHonorResult">
        <result property="honorId"    column="honor_id"    />
        <result property="teacherId"    column="teacher_id"    />
        <result property="name"    column="name"    />
        <result property="proofunit"    column="proofunit"    />
        <result property="level"    column="level"    />
        <result property="awardTime"    column="awardTime"    />
        <result property="awardPerson"    column="awardPerson"    />
        <result property="year"    column="year"    />
        <result property="certificate"    column="certificate"    />
        <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="selectSysTeacherHonorVo">
        select honor_id, teacher_id, name, proofunit, level, awardTime, awardPerson, year, certificate, check_status, check_person, college, returnReason, submitYear from sys_teacher_honor
    </sql>

    <select id="selectSysTeacherHonorList" parameterType="SysTeacherHonor" resultMap="SysTeacherHonorResult">
        <include refid="selectSysTeacherHonorVo"/>
        <where>  
            <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
            <if test="proofunit != null  and proofunit != ''"> and proofunit = #{proofunit}</if>
            <if test="level != null  and level != ''"> and level = #{level}</if>
            <if test="awardTime != null  and awardTime != ''"> and awardTime = #{awardTime}</if>
            <if test="awardPerson != null  and awardPerson != ''"> and awardPerson = #{awardPerson}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="certificate != null  and certificate != ''"> and certificate = #{certificate}</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="selectSysTeacherHonorByHonorId" parameterType="Long" resultMap="SysTeacherHonorResult">
        <include refid="selectSysTeacherHonorVo"/>
        where honor_id = #{honorId}
    </select>
        
    <insert id="insertSysTeacherHonor" parameterType="SysTeacherHonor" useGeneratedKeys="true" keyProperty="honorId">
        insert into sys_teacher_honor
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">teacher_id,</if>
            <if test="name != null">name,</if>
            <if test="proofunit != null">proofunit,</if>
            <if test="level != null">level,</if>
            <if test="awardTime != null">awardTime,</if>
            <if test="awardPerson != null">awardPerson,</if>
            <if test="year != null">year,</if>
            <if test="certificate != null">certificate,</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="proofunit != null">#{proofunit},</if>
            <if test="level != null">#{level},</if>
            <if test="awardTime != null">#{awardTime},</if>
            <if test="awardPerson != null">#{awardPerson},</if>
            <if test="year != null">#{year},</if>
            <if test="certificate != null">#{certificate},</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="updateSysTeacherHonor" parameterType="SysTeacherHonor">
        update sys_teacher_honor
        <trim prefix="SET" suffixOverrides=",">
            <if test="teacherId != null">teacher_id = #{teacherId},</if>
            <if test="name != null">name = #{name},</if>
            <if test="proofunit != null">proofunit = #{proofunit},</if>
            <if test="level != null">level = #{level},</if>
            <if test="awardTime != null">awardTime = #{awardTime},</if>
            <if test="awardPerson != null">awardPerson = #{awardPerson},</if>
            <if test="year != null">year = #{year},</if>
            <if test="certificate != null">certificate = #{certificate},</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 honor_id = #{honorId}
    </update>

    <delete id="deleteSysTeacherHonorByHonorId" parameterType="Long">
        delete from sys_teacher_honor where honor_id = #{honorId}
    </delete>

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