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

    <resultMap type="SysTeacherConferenceMeetingMaterials" id="SysTeacherConferenceMeetingMaterialsResult">
        <result property="id" column="id"/>
        <result property="subject" column="subject"/>
        <result property="organizationalUnit" column="organizational_unit"/>
        <result property="startTime" column="start_time"/>
        <result property="place" column="place"/>
        <result property="fdyName" column="fdy_name"/>
        <result property="fillingYear" column="filling_year"/>
        <result property="fillingMonth" column="filling_month"/>
    </resultMap>

    <sql id="selectSysTeacherConferenceMeetingMaterialsVo">
        select id,
               subject,
               organizational_unit,
               start_time,
               place,
               fdy_name,
               filling_year,
               filling_month
        from sys_teacher_conference_meeting_materials
    </sql>

    <select id="selectSysTeacherConferenceMeetingMaterialsList" parameterType="SysTeacherConferenceMeetingMaterials"
            resultMap="SysTeacherConferenceMeetingMaterialsResult">
        <include refid="selectSysTeacherConferenceMeetingMaterialsVo"/>
        <where>
            <if test="subject != null  and subject != ''">and subject = #{subject}</if>
            <if test="organizationalUnit != null  and organizationalUnit != ''">and organizational_unit =
                #{organizationalUnit}
            </if>
            <if test="startTime != null ">and start_time = #{startTime}</if>
            <if test="place != null  and place != ''"> and place like concat('%', #{place}, '%')</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="selectSysTeacherConferenceMeetingMaterialsByFdyName" parameterType="String"
            resultMap="SysTeacherConferenceMeetingMaterialsResult">
        <include refid="selectSysTeacherConferenceMeetingMaterialsVo"/>
        <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="selectSysTeacherConferenceMeetingMaterialsById" parameterType="Long"
            resultMap="SysTeacherConferenceMeetingMaterialsResult">
        <include refid="selectSysTeacherConferenceMeetingMaterialsVo"/>
        where id = #{id}
    </select>

    <insert id="insertSysTeacherConferenceMeetingMaterials" parameterType="SysTeacherConferenceMeetingMaterials">
        insert into sys_teacher_conference_meeting_materials
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="subject != null and subject != ''">subject,</if>
            <if test="organizationalUnit != null and organizationalUnit != ''">organizational_unit,</if>
            <if test="startTime != null">start_time,</if>
            <if test="place != null and place != ''">place,</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="subject != null and subject != ''">#{subject},</if>
            <if test="organizationalUnit != null and organizationalUnit != ''">#{organizationalUnit},</if>
            <if test="startTime != null">#{startTime},</if>
            <if test="place != null and place != ''">#{place},</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="updateSysTeacherConferenceMeetingMaterials" parameterType="SysTeacherConferenceMeetingMaterials">
        update sys_teacher_conference_meeting_materials
        <trim prefix="SET" suffixOverrides=",">
            <if test="subject != null and subject != ''">subject = #{subject},</if>
            <if test="organizationalUnit != null and organizationalUnit != ''">organizational_unit =
                #{organizationalUnit},
            </if>
            <if test="startTime != null">start_time = #{startTime},</if>
            <if test="place != null and place != ''">place = #{place},</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="deleteSysTeacherConferenceMeetingMaterialsById" parameterType="Long">
        delete
        from sys_teacher_conference_meeting_materials
        where id = #{id}
    </delete>

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