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

    <resultMap type="SysTeacherKpiFillingBusinessWork" id="SysTeacherKpiFillingBusinessWorkResult">
        <result property="id" column="id"/>
        <result property="stuLeaveMaterialsScoring" column="stu_leave_materials_scoring"/>
        <result property="stuFillingMaterialsScoring" column="stu_filling_materials_scoring"/>
        <result property="stuBasicDataScoring" column="stu_basic_data_scoring"/>
        <result property="stuDisciplinaryViolationScoring" column="stu_disciplinary_violation_scoring"/>
        <result property="handleEventsScoring" column="handle_events_scoring"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>

    <sql id="selectSysTeacherKpiFillingBusinessWorkVo">
        select id,
               stu_leave_materials_scoring,
               stu_filling_materials_scoring,
               stu_basic_data_scoring,
               stu_disciplinary_violation_scoring,
               handle_events_scoring,
               fdy_name,
               filling_year,
               filling_month
        from sys_teacher_kpi_filling_business_work
    </sql>

    <select id="selectSysTeacherKpiFillingBusinessWorkList" parameterType="SysTeacherKpiFillingBusinessWork"
            resultMap="SysTeacherKpiFillingBusinessWorkResult">
        <include refid="selectSysTeacherKpiFillingBusinessWorkVo"/>
        <where>
            <if test="stuLeaveMaterialsScoring != null ">and stu_leave_materials_scoring = #{stuLeaveMaterialsScoring}
            </if>
            <if test="stuFillingMaterialsScoring != null ">and stu_filling_materials_scoring =
                #{stuFillingMaterialsScoring}
            </if>
            <if test="stuBasicDataScoring != null ">and stu_basic_data_scoring = #{stuBasicDataScoring}</if>
            <if test="stuDisciplinaryViolationScoring != null ">and stu_disciplinary_violation_scoring =
                #{stuDisciplinaryViolationScoring}
            </if>
            <if test="handleEventsScoring != null ">and handle_events_scoring = #{handleEventsScoring}</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="selectSysTeacherKpiFillingBusinessWorkById" parameterType="Long"
            resultMap="SysTeacherKpiFillingBusinessWorkResult">
        <include refid="selectSysTeacherKpiFillingBusinessWorkVo"/>
        where id = #{id}
    </select>

    <!--根据名称、年份、月份查询-->
    <select id="selectSysTeacherKpiFillingBusinessWorkByFdyName" parameterType="String"
            resultMap="SysTeacherKpiFillingBusinessWorkResult">
        <include refid="selectSysTeacherKpiFillingBusinessWorkVo"/>
        <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>

    <insert id="insertSysTeacherKpiFillingBusinessWork" parameterType="SysTeacherKpiFillingBusinessWork">
        insert into sys_teacher_kpi_filling_business_work
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="stuLeaveMaterialsScoring != null">stu_leave_materials_scoring,</if>
            <if test="stuFillingMaterialsScoring != null">stu_filling_materials_scoring,</if>
            <if test="stuBasicDataScoring != null">stu_basic_data_scoring,</if>
            <if test="stuDisciplinaryViolationScoring != null">stu_disciplinary_violation_scoring,</if>
            <if test="handleEventsScoring != null">handle_events_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="stuLeaveMaterialsScoring != null">#{stuLeaveMaterialsScoring},</if>
            <if test="stuFillingMaterialsScoring != null">#{stuFillingMaterialsScoring},</if>
            <if test="stuBasicDataScoring != null">#{stuBasicDataScoring},</if>
            <if test="stuDisciplinaryViolationScoring != null">#{stuDisciplinaryViolationScoring},</if>
            <if test="handleEventsScoring != null">#{handleEventsScoring},</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="updateSysTeacherKpiFillingBusinessWork" parameterType="SysTeacherKpiFillingBusinessWork">
        update sys_teacher_kpi_filling_business_work
        <trim prefix="SET" suffixOverrides=",">
            <if test="stuLeaveMaterialsScoring != null">stu_leave_materials_scoring = #{stuLeaveMaterialsScoring},</if>
            <if test="stuFillingMaterialsScoring != null">stu_filling_materials_scoring =
                #{stuFillingMaterialsScoring},
            </if>
            <if test="stuBasicDataScoring != null">stu_basic_data_scoring = #{stuBasicDataScoring},</if>
            <if test="stuDisciplinaryViolationScoring != null">stu_disciplinary_violation_scoring =
                #{stuDisciplinaryViolationScoring},
            </if>
            <if test="handleEventsScoring != null">handle_events_scoring = #{handleEventsScoring},</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="deleteSysTeacherKpiFillingBusinessWorkById" parameterType="Long">
        delete
        from sys_teacher_kpi_filling_business_work
        where id = #{id}
    </delete>

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