<?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.SysTeacherKpiFillingAMgtMapper">

    <resultMap type="SysTeacherKpiFillingAMgt" id="SysTeacherKpiFillingAMgtResult">
        <result property="id" column="id"/>
        <result property="dutyWorkScoring" column="duty_work_scoring"/>
        <result property="conferenceScoring" column="conference_scoring"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>

    <sql id="selectSysTeacherKpiFillingAMgtVo">
        select id, duty_work_scoring, conference_scoring, fdy_name, filling_year, filling_month
        from sys_teacher_kpi_filling_a_mgt
    </sql>

    <select id="selectSysTeacherKpiFillingAMgtList" parameterType="SysTeacherKpiFillingAMgt"
            resultMap="SysTeacherKpiFillingAMgtResult">
        <include refid="selectSysTeacherKpiFillingAMgtVo"/>
        <where>
            <if test="dutyWorkScoring != null ">and duty_work_scoring = #{dutyWorkScoring}</if>
            <if test="conferenceScoring != null ">and conference_scoring = #{conferenceScoring}</if>
            <if test="fdyName != null  and fdyName != ''">and fdy_name like concat('%', #{fdyName}, '%')</if>
            <if test="fillingYear != null  and fillingYear != ''">and filling_year = #{fillingYear}</if>
            <if test="fillingMonth != null  and fillingMonth != ''">and filling_month = #{fillingMonth}</if>
        </where>
        order by id desc
    </select>

    <!--根据名称、年份、月份查询-->
    <select id="selectSysTeacherKpiFillingAMgtByFdyName" parameterType="String"
            resultMap="SysTeacherKpiFillingAMgtResult">
        <include refid="selectSysTeacherKpiFillingAMgtVo"/>
        <where>
            <if test="fdyName != null and fdyName != ''">
                and fdy_name = #{fdyName}
            </if>
            <if test="fillingYear != null and fillingYear != ''">
                and filling_year = #{fillingYear}
            </if>
            <if test="fillingMonth != null and fillingMonth != ''">
                and filling_month = #{fillingMonth}
            </if>
        </where>
        order by id desc
    </select>

    <select id="selectSysTeacherKpiFillingAMgtById" parameterType="Long" resultMap="SysTeacherKpiFillingAMgtResult">
        <include refid="selectSysTeacherKpiFillingAMgtVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysTeacherKpiFillingAMgt" parameterType="SysTeacherKpiFillingAMgt">
        insert into sys_teacher_kpi_filling_a_mgt
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="dutyWorkScoring != null">duty_work_scoring,</if>
            <if test="conferenceScoring != null">conference_scoring,</if>
            <if test="fdyName != null and fdyName != ''">fdy_name,</if>
            <if test="fillingYear != null and fillingYear != ''">filling_year,</if>
            <if test="fillingMonth != null and fillingMonth != ''">filling_month,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="dutyWorkScoring != null">#{dutyWorkScoring},</if>
            <if test="conferenceScoring != null">#{conferenceScoring},</if>
            <if test="fdyName != null and fdyName != ''">#{fdyName},</if>
            <if test="fillingYear != null and fillingYear != ''">#{fillingYear},</if>
            <if test="fillingMonth != null and fillingMonth != ''">#{fillingMonth},</if>
        </trim>
    </insert>

    <update id="updateSysTeacherKpiFillingAMgt" parameterType="SysTeacherKpiFillingAMgt">
        update sys_teacher_kpi_filling_a_mgt
        <trim prefix="SET" suffixOverrides=",">
            <if test="dutyWorkScoring != null">duty_work_scoring = #{dutyWorkScoring},</if>
            <if test="conferenceScoring != null">conference_scoring = #{conferenceScoring},</if>
            <if test="fdyName != null and fdyName != ''">fdy_name = #{fdyName},</if>
            <if test="fillingYear != null and fillingYear != ''">filling_year = #{fillingYear},</if>
            <if test="fillingMonth != null and fillingMonth != ''">filling_month = #{fillingMonth},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysTeacherKpiFillingAMgtById" parameterType="Long">
        delete
        from sys_teacher_kpi_filling_a_mgt
        where id = #{id}
    </delete>

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