<?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.SysTeacherAppraiseMapper">
    
    <resultMap type="SysTeacherAppraise" id="SysTeacherAppraiseResult">
        <result property="appraiseId"    column="appraise_id"    />
        <result property="teacherId"    column="teacher_id"    />
        <result property="year"    column="year"    />
        <result property="result"    column="result"    />
    </resultMap>

    <sql id="selectSysTeacherAppraiseVo">
        select appraise_id, teacher_id, year, result from sys_teacher_appraise
    </sql>

    <select id="selectSysTeacherAppraiseList" parameterType="SysTeacherAppraise" resultMap="SysTeacherAppraiseResult">
        <include refid="selectSysTeacherAppraiseVo"/>
        <where>  
            <if test="teacherId != null "> and teacher_id = #{teacherId}</if>
            <if test="year != null  and year != ''"> and year = #{year}</if>
            <if test="result != null  and result != ''"> and result = #{result}</if>
        </where>
    </select>
    
    <select id="selectSysTeacherAppraiseByAppraiseId" parameterType="Long" resultMap="SysTeacherAppraiseResult">
        <include refid="selectSysTeacherAppraiseVo"/>
        where appraise_id = #{appraiseId}
    </select>
        
    <insert id="insertSysTeacherAppraise" parameterType="SysTeacherAppraise" useGeneratedKeys="true" keyProperty="appraiseId">
        insert into sys_teacher_appraise
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">teacher_id,</if>
            <if test="year != null">year,</if>
            <if test="result != null">result,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="teacherId != null">#{teacherId},</if>
            <if test="year != null">#{year},</if>
            <if test="result != null">#{result},</if>
         </trim>
    </insert>

    <update id="updateSysTeacherAppraise" parameterType="SysTeacherAppraise">
        update sys_teacher_appraise
        <trim prefix="SET" suffixOverrides=",">
            <if test="teacherId != null">teacher_id = #{teacherId},</if>
            <if test="year != null">year = #{year},</if>
            <if test="result != null">result = #{result},</if>
        </trim>
        where appraise_id = #{appraiseId}
    </update>

    <delete id="deleteSysTeacherAppraiseByAppraiseId" parameterType="Long">
        delete from sys_teacher_appraise where appraise_id = #{appraiseId}
    </delete>

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