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

    <resultMap type="SysTeacherKpiFillingBonusPointsMaterials" id="SysTeacherKpiFillingBonusPointsMaterialsResult">
        <result property="id" column="id"/>
        <result property="bonusType" column="bonus_type"/>
        <result property="bonusScoring" column="bonus_scoring"/>
        <result property="mainContent" column="main_content"/>
        <result property="developmentTime" column="development_time"/>
        <result property="photo" column="photo"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
        <result property="classType" column="class_type"/>
    </resultMap>

    <sql id="selectSysTeacherKpiFillingBonusPointsMaterialsVo">
        select id, bonus_type, bonus_scoring, main_content, development_time, photo, fdy_name, filling_year, filling_month, class_type
        from sys_teacher_kpi_filling_bonus_points_materials
    </sql>

    <select id="selectSysTeacherKpiFillingBonusPointsMaterialsList" parameterType="SysTeacherKpiFillingBonusPointsMaterials"
            resultMap="SysTeacherKpiFillingBonusPointsMaterialsResult">
        <include refid="selectSysTeacherKpiFillingBonusPointsMaterialsVo"/>
        <where>
            <if test="bonusType != null and bonusType != ''">and bonus_type = #{bonusType}</if>
            <if test="bonusScoring != null">and bonus_scoring = #{bonusScoring}</if>
            <if test="mainContent != null and mainContent != ''">and main_content like concat('%', #{mainContent}, '%')</if>
            <if test="developmentTime != null">and development_time = #{developmentTime}</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>
            <if test="classType != null and classType != ''">and class_type = #{classType}</if>
        </where>
        order by id desc
    </select>

    <select id="selectSysTeacherKpiFillingBonusPointsMaterialsByFdyName" parameterType="String"
            resultMap="SysTeacherKpiFillingBonusPointsMaterialsResult">
        <include refid="selectSysTeacherKpiFillingBonusPointsMaterialsVo"/>
        <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>
            <if test="classType != null and classType != ''">
                and class_type = #{classType}
            </if>
            <if test="bonusType != null and bonusType != ''">
                and bonus_type = #{bonusType}
            </if>
        </where>
        order by id desc
    </select>

    <select id="selectSysTeacherKpiFillingBonusPointsMaterialsById" parameterType="Long"
            resultMap="SysTeacherKpiFillingBonusPointsMaterialsResult">
        <include refid="selectSysTeacherKpiFillingBonusPointsMaterialsVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysTeacherKpiFillingBonusPointsMaterials" parameterType="SysTeacherKpiFillingBonusPointsMaterials"
            useGeneratedKeys="true" keyProperty="id">
        insert into sys_teacher_kpi_filling_bonus_points_materials
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="bonusType != null and bonusType != ''">bonus_type,</if>
            <if test="bonusScoring != null">bonus_scoring,</if>
            <if test="mainContent != null and mainContent != ''">main_content,</if>
            <if test="developmentTime != null">development_time,</if>
            <if test="photo != null and photo != ''">photo,</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>
            <if test="classType != null and classType != ''">class_type,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="bonusType != null and bonusType != ''">#{bonusType},</if>
            <if test="bonusScoring != null">#{bonusScoring},</if>
            <if test="mainContent != null and mainContent != ''">#{mainContent},</if>
            <if test="developmentTime != null">#{developmentTime},</if>
            <if test="photo != null and photo != ''">#{photo},</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>
            <if test="classType != null and classType != ''">#{classType},</if>
        </trim>
    </insert>

    <update id="updateSysTeacherKpiFillingBonusPointsMaterials" parameterType="SysTeacherKpiFillingBonusPointsMaterials">
        update sys_teacher_kpi_filling_bonus_points_materials
        <trim prefix="SET" suffixOverrides=",">
            <if test="bonusType != null and bonusType != ''">bonus_type = #{bonusType},</if>
            <if test="bonusScoring != null">bonus_scoring = #{bonusScoring},</if>
            <if test="mainContent != null and mainContent != ''">main_content = #{mainContent},</if>
            <if test="developmentTime != null">development_time = #{developmentTime},</if>
            <if test="photo != null">photo = #{photo},</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>
            <if test="classType != null and classType != ''">class_type = #{classType},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysTeacherKpiFillingBonusPointsMaterialsById" parameterType="Long">
        delete
        from sys_teacher_kpi_filling_bonus_points_materials
        where id = #{id}
    </delete>

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