<?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.SysPerformanceRwMapper">
    
    <resultMap type="SysPerformanceRw" id="SysPerformanceRwResult">
        <result property="id"    column="id"    />
        <result property="rwType"    column="rw_type"    />
        <result property="rwTime"    column="rw_time"    />
        <result property="rwPlace"    column="rw_place"    />
        <result property="rwParticipate"    column="rw_participate"    />
        <result property="rwPeople"    column="rw_people"    />
        <result property="rwTheme"    column="rw_theme"    />
        <result property="rwSituation"    column="rw_situation"    />
        <result property="rwStu"    column="rw_stu"    />
        <result property="rwProportion"    column="rw_proportion"    />
        <result property="rwFile"    column="rw_file"    />
        <result property="rwNews"    column="rw_news"    />
        <result property="rwPicture"    column="rw_picture"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>

    <sql id="selectSysPerformanceRwVo">
        select id, rw_type, rw_time, rw_place, rw_participate, rw_people, rw_theme, rw_situation, rw_stu, rw_proportion, rw_file, rw_news, rw_picture, years, fd_name from sys_performance_rw
    </sql>

    <select id="selectSysPerformanceRwList" parameterType="SysPerformanceRw" resultMap="SysPerformanceRwResult">
        <include refid="selectSysPerformanceRwVo"/>
        <where>  
            <if test="rwType != null  and rwType != ''"> and rw_type = #{rwType}</if>
            <if test="rwTime != null "> and rw_time = #{rwTime}</if>
            <if test="rwPlace != null  and rwPlace != ''"> and rw_place = #{rwPlace}</if>
            <if test="rwParticipate != null  and rwParticipate != ''"> and rw_participate = #{rwParticipate}</if>
            <if test="rwPeople != null  and rwPeople != ''"> and rw_people = #{rwPeople}</if>
            <if test="rwTheme != null  and rwTheme != ''"> and rw_theme = #{rwTheme}</if>
            <if test="rwSituation != null  and rwSituation != ''"> and rw_situation = #{rwSituation}</if>
            <if test="rwStu != null  and rwStu != ''"> and rw_stu = #{rwStu}</if>
            <if test="rwProportion != null  and rwProportion != ''"> and rw_proportion = #{rwProportion}</if>
            <if test="rwFile != null  and rwFile != ''"> and rw_file = #{rwFile}</if>
            <if test="rwNews != null  and rwNews != ''"> and rw_news = #{rwNews}</if>
            <if test="rwPicture != null  and rwPicture != ''"> and rw_picture = #{rwPicture}</if>
            <if test="years != null  and years != ''"> and years = #{years}</if>
            <if test="fdName != null  and fdName != ''"> and fd_name like concat('%', #{fdName}, '%')</if>
        </where>
    </select>
    
    <select id="selectSysPerformanceRwById" parameterType="Long" resultMap="SysPerformanceRwResult">
        <include refid="selectSysPerformanceRwVo"/>
        where id = #{id}
    </select>

    <!--根据填报人、年份查询-->
    <select id="selectSysPerformanceRwByFdyName" parameterType="String"
            resultMap="SysPerformanceRwResult">
        <include refid="selectSysPerformanceRwVo"/>
        <where>
            <if test="fdName != null and fdName != ''">
                and fd_name = #{fdName}
            </if>
            <if test="years != null and years != ''">
                and years = #{years}
            </if>

        </where>
        order by id desc
    </select>
        
    <insert id="insertSysPerformanceRw" parameterType="SysPerformanceRw" useGeneratedKeys="true" keyProperty="id">
        insert into sys_performance_rw
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="rwType != null">rw_type,</if>
            <if test="rwTime != null">rw_time,</if>
            <if test="rwPlace != null">rw_place,</if>
            <if test="rwParticipate != null">rw_participate,</if>
            <if test="rwPeople != null">rw_people,</if>
            <if test="rwTheme != null">rw_theme,</if>
            <if test="rwSituation != null">rw_situation,</if>
            <if test="rwStu != null">rw_stu,</if>
            <if test="rwProportion != null">rw_proportion,</if>
            <if test="rwFile != null">rw_file,</if>
            <if test="rwNews != null">rw_news,</if>
            <if test="rwPicture != null">rw_picture,</if>
            <if test="years != null">years,</if>
            <if test="fdName != null">fd_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="rwType != null">#{rwType},</if>
            <if test="rwTime != null">#{rwTime},</if>
            <if test="rwPlace != null">#{rwPlace},</if>
            <if test="rwParticipate != null">#{rwParticipate},</if>
            <if test="rwPeople != null">#{rwPeople},</if>
            <if test="rwTheme != null">#{rwTheme},</if>
            <if test="rwSituation != null">#{rwSituation},</if>
            <if test="rwStu != null">#{rwStu},</if>
            <if test="rwProportion != null">#{rwProportion},</if>
            <if test="rwFile != null">#{rwFile},</if>
            <if test="rwNews != null">#{rwNews},</if>
            <if test="rwPicture != null">#{rwPicture},</if>
            <if test="years != null">#{years},</if>
            <if test="fdName != null">#{fdName},</if>
         </trim>
    </insert>

    <update id="updateSysPerformanceRw" parameterType="SysPerformanceRw">
        update sys_performance_rw
        <trim prefix="SET" suffixOverrides=",">
            <if test="rwType != null">rw_type = #{rwType},</if>
            <if test="rwTime != null">rw_time = #{rwTime},</if>
            <if test="rwPlace != null">rw_place = #{rwPlace},</if>
            <if test="rwParticipate != null">rw_participate = #{rwParticipate},</if>
            <if test="rwPeople != null">rw_people = #{rwPeople},</if>
            <if test="rwTheme != null">rw_theme = #{rwTheme},</if>
            <if test="rwSituation != null">rw_situation = #{rwSituation},</if>
            <if test="rwStu != null">rw_stu = #{rwStu},</if>
            <if test="rwProportion != null">rw_proportion = #{rwProportion},</if>
            <if test="rwFile != null">rw_file = #{rwFile},</if>
            <if test="rwNews != null">rw_news = #{rwNews},</if>
            <if test="rwPicture != null">rw_picture = #{rwPicture},</if>
            <if test="years != null">years = #{years},</if>
            <if test="fdName != null">fd_name = #{fdName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysPerformanceRwById" parameterType="Long">
        delete from sys_performance_rw where id = #{id}
    </delete>

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