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

    <resultMap type="SysTeacherKpiFillingNegativeList" id="SysTeacherKpiFillingNegativeListResult">
        <result property="id" column="id"/>
        <result property="moralityAndBehavior" column="morality_and_behavior"/>
        <result property="speech" column="speech"/>
        <result property="complaint" column="complaint"/>
        <result property="offense" column="offense"/>
        <result property="emergency" column="emergency"/>
        <result property="punishment" column="punishment"/>
        <result property="practiceFraud" column="practice_fraud"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>

    <sql id="selectSysTeacherKpiFillingNegativeListVo">
        select id,
               morality_and_behavior,
               speech,
               complaint,
               offense,
               emergency,
               punishment,
               practice_fraud,
               fdy_name,
               filling_year,
               filling_month
        from sys_teacher_kpi_filling_negative_list
    </sql>

    <select id="selectSysTeacherKpiFillingNegativeListList" parameterType="SysTeacherKpiFillingNegativeList"
            resultMap="SysTeacherKpiFillingNegativeListResult">
        <include refid="selectSysTeacherKpiFillingNegativeListVo"/>
        <where>
            <if test="moralityAndBehavior != null ">and morality_and_behavior = #{moralityAndBehavior}</if>
            <if test="speech != null ">and speech = #{speech}</if>
            <if test="complaint != null ">and complaint = #{complaint}</if>
            <if test="offense != null ">and offense = #{offense}</if>
            <if test="emergency != null ">and emergency = #{emergency}</if>
            <if test="punishment != null ">and punishment = #{punishment}</if>
            <if test="practiceFraud != null ">and practice_fraud = #{practiceFraud}</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="selectSysTeacherKpiFillingNegativeListByFdyName" parameterType="String"
            resultMap="SysTeacherKpiFillingNegativeListResult">
        <include refid="selectSysTeacherKpiFillingNegativeListVo"/>
        <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="selectSysTeacherKpiFillingNegativeListById" parameterType="Long"
            resultMap="SysTeacherKpiFillingNegativeListResult">
        <include refid="selectSysTeacherKpiFillingNegativeListVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysTeacherKpiFillingNegativeList" parameterType="SysTeacherKpiFillingNegativeList"
            useGeneratedKeys="true" keyProperty="id">
        insert into sys_teacher_kpi_filling_negative_list
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="moralityAndBehavior != null">morality_and_behavior,</if>
            <if test="speech != null">speech,</if>
            <if test="complaint != null">complaint,</if>
            <if test="offense != null">offense,</if>
            <if test="emergency != null">emergency,</if>
            <if test="punishment != null">punishment,</if>
            <if test="practiceFraud != null">practice_fraud,</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="moralityAndBehavior != null">#{moralityAndBehavior},</if>
            <if test="speech != null">#{speech},</if>
            <if test="complaint != null">#{complaint},</if>
            <if test="offense != null">#{offense},</if>
            <if test="emergency != null">#{emergency},</if>
            <if test="punishment != null">#{punishment},</if>
            <if test="practiceFraud != null">#{practiceFraud},</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="updateSysTeacherKpiFillingNegativeList" parameterType="SysTeacherKpiFillingNegativeList">
        update sys_teacher_kpi_filling_negative_list
        <trim prefix="SET" suffixOverrides=",">
            <if test="moralityAndBehavior != null">morality_and_behavior = #{moralityAndBehavior},</if>
            <if test="speech != null">speech = #{speech},</if>
            <if test="complaint != null">complaint = #{complaint},</if>
            <if test="offense != null">offense = #{offense},</if>
            <if test="emergency != null">emergency = #{emergency},</if>
            <if test="punishment != null">punishment = #{punishment},</if>
            <if test="practiceFraud != null">practice_fraud = #{practiceFraud},</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="deleteSysTeacherKpiFillingNegativeListById" parameterType="Long">
        delete
        from sys_teacher_kpi_filling_negative_list
        where id = #{id}
    </delete>

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