<?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.SysPerformanceActiveMapper">
    
    <resultMap type="SysPerformanceActive" id="SysPerformanceActiveResult">
        <result property="id"    column="id"    />
        <result property="activeType"    column="active_type"    />
        <result property="gzsTime"    column="gzs_time"    />
        <result property="gzsPlace"    column="gzs_place"    />
        <result property="gzsParticipate"    column="gzs_participate"    />
        <result property="gzsFdy"    column="gzs_fdy"    />
        <result property="gzsStu"    column="gzs_stu"    />
        <result property="gzsTheme"    column="gzs_theme"    />
        <result property="gzsIntroduce"    column="gzs_introduce"    />
        <result property="gzsPicture"    column="gzs_picture"    />
        <result property="gzsNews"    column="gzs_news"    />
        <result property="gzsProportion"    column="gzs_proportion"    />
        <result property="years"    column="years"    />
        <result property="fdName"    column="fd_name"    />
    </resultMap>

    <sql id="selectSysPerformanceActiveVo">
        select id, active_type, gzs_time, gzs_place, gzs_participate, gzs_fdy, gzs_stu, gzs_theme, gzs_introduce, gzs_picture, gzs_news, gzs_proportion, years, fd_name from sys_performance_active
    </sql>

    <!--根据填报人、年份查询-->
    <select id="selectSysPerformanceActiveByFdyName" parameterType="String"
            resultMap="SysPerformanceActiveResult">
        <include refid="selectSysPerformanceActiveVo"/>
        <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>



    <select id="selectSysPerformanceActiveList" parameterType="SysPerformanceActive" resultMap="SysPerformanceActiveResult">
        <include refid="selectSysPerformanceActiveVo"/>
        <where>  
            <if test="activeType != null  and activeType != ''"> and active_type = #{activeType}</if>
            <if test="gzsTime != null "> and gzs_time = #{gzsTime}</if>
            <if test="gzsPlace != null  and gzsPlace != ''"> and gzs_place = #{gzsPlace}</if>
            <if test="gzsParticipate != null  and gzsParticipate != ''"> and gzs_participate = #{gzsParticipate}</if>
            <if test="gzsFdy != null  and gzsFdy != ''"> and gzs_fdy = #{gzsFdy}</if>
            <if test="gzsStu != null  and gzsStu != ''"> and gzs_stu = #{gzsStu}</if>
            <if test="gzsTheme != null  and gzsTheme != ''"> and gzs_theme = #{gzsTheme}</if>
            <if test="gzsIntroduce != null  and gzsIntroduce != ''"> and gzs_introduce = #{gzsIntroduce}</if>
            <if test="gzsPicture != null  and gzsPicture != ''"> and gzs_picture = #{gzsPicture}</if>
            <if test="gzsNews != null  and gzsNews != ''"> and gzs_news = #{gzsNews}</if>
            <if test="gzsProportion != null  and gzsProportion != ''"> and gzs_proportion = #{gzsProportion}</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="selectSysPerformanceActiveById" parameterType="Long" resultMap="SysPerformanceActiveResult">
        <include refid="selectSysPerformanceActiveVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSysPerformanceActive" parameterType="SysPerformanceActive" useGeneratedKeys="true" keyProperty="id">
        insert into sys_performance_active
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="activeType != null">active_type,</if>
            <if test="gzsTime != null">gzs_time,</if>
            <if test="gzsPlace != null">gzs_place,</if>
            <if test="gzsParticipate != null">gzs_participate,</if>
            <if test="gzsFdy != null">gzs_fdy,</if>
            <if test="gzsStu != null">gzs_stu,</if>
            <if test="gzsTheme != null">gzs_theme,</if>
            <if test="gzsIntroduce != null">gzs_introduce,</if>
            <if test="gzsPicture != null">gzs_picture,</if>
            <if test="gzsNews != null">gzs_news,</if>
            <if test="gzsProportion != null">gzs_proportion,</if>
            <if test="years != null">years,</if>
            <if test="fdName != null">fd_name,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="activeType != null">#{activeType},</if>
            <if test="gzsTime != null">#{gzsTime},</if>
            <if test="gzsPlace != null">#{gzsPlace},</if>
            <if test="gzsParticipate != null">#{gzsParticipate},</if>
            <if test="gzsFdy != null">#{gzsFdy},</if>
            <if test="gzsStu != null">#{gzsStu},</if>
            <if test="gzsTheme != null">#{gzsTheme},</if>
            <if test="gzsIntroduce != null">#{gzsIntroduce},</if>
            <if test="gzsPicture != null">#{gzsPicture},</if>
            <if test="gzsNews != null">#{gzsNews},</if>
            <if test="gzsProportion != null">#{gzsProportion},</if>
            <if test="years != null">#{years},</if>
            <if test="fdName != null">#{fdName},</if>
         </trim>
    </insert>

    <update id="updateSysPerformanceActive" parameterType="SysPerformanceActive">
        update sys_performance_active
        <trim prefix="SET" suffixOverrides=",">
            <if test="activeType != null">active_type = #{activeType},</if>
            <if test="gzsTime != null">gzs_time = #{gzsTime},</if>
            <if test="gzsPlace != null">gzs_place = #{gzsPlace},</if>
            <if test="gzsParticipate != null">gzs_participate = #{gzsParticipate},</if>
            <if test="gzsFdy != null">gzs_fdy = #{gzsFdy},</if>
            <if test="gzsStu != null">gzs_stu = #{gzsStu},</if>
            <if test="gzsTheme != null">gzs_theme = #{gzsTheme},</if>
            <if test="gzsIntroduce != null">gzs_introduce = #{gzsIntroduce},</if>
            <if test="gzsPicture != null">gzs_picture = #{gzsPicture},</if>
            <if test="gzsNews != null">gzs_news = #{gzsNews},</if>
            <if test="gzsProportion != null">gzs_proportion = #{gzsProportion},</if>
            <if test="years != null">years = #{years},</if>
            <if test="fdName != null">fd_name = #{fdName},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSysPerformanceActiveById" parameterType="Long">
        delete from sys_performance_active where id = #{id}
    </delete>

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