<?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.staff.mapper.SysRfileMapper">
    
    <resultMap type="SysRfile" id="SysRfileResult">
        <result property="rfileId"    column="rfile_id"    />
        <result property="rfileTitle"    column="rfile_title"    />
        <result property="rfilePath"    column="rfile_path"    />
        <result property="rfileType"    column="rfile_type"    />
        <result property="rfileDate"    column="rfile_date"    />
    </resultMap>

    <sql id="selectSysRfileVo">
        select rfile_id, rfile_title, rfile_path, rfile_type, rfile_date from sys_rfile
    </sql>

    <select id="selectSysRfileList" parameterType="SysRfile" resultMap="SysRfileResult">
        <include refid="selectSysRfileVo"/>
        <where>  
            <if test="rfileTitle != null  and rfileTitle != ''"> and rfile_title like concat('%', #{rfileTitle}, '%')</if>
            <if test="rfilePath != null  and rfilePath != ''"> and rfile_path like concat('%', #{rfilePath}, '%')</if>
            <if test="rfileType != null  and rfileType != ''"> and rfile_type like concat('%', #{rfileType}, '%')</if>
            <if test="rfileDate != null "> and rfile_date = #{rfileDate}</if>
        </where>
    </select>
    
    <select id="selectSysRfileByRfileId" parameterType="Long" resultMap="SysRfileResult">
        <include refid="selectSysRfileVo"/>
        where rfile_id = #{rfileId}
    </select>
        
    <insert id="insertSysRfile" parameterType="SysRfile">
        insert into sys_rfile
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="rfileId != null">rfile_id,</if>
            <if test="rfileTitle != null and rfileTitle != ''">rfile_title,</if>
            <if test="rfilePath != null and rfilePath != ''">rfile_path,</if>
            <if test="rfileType != null and rfileType != ''">rfile_type,</if>
            <if test="rfileDate != null">rfile_date,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="rfileId != null">#{rfileId},</if>
            <if test="rfileTitle != null and rfileTitle != ''">#{rfileTitle},</if>
            <if test="rfilePath != null and rfilePath != ''">#{rfilePath},</if>
            <if test="rfileType != null and rfileType != ''">#{rfileType},</if>
            <if test="rfileDate != null">#{rfileDate},</if>
         </trim>
    </insert>

    <update id="updateSysRfile" parameterType="SysRfile">
        update sys_rfile
        <trim prefix="SET" suffixOverrides=",">
            <if test="rfileTitle != null and rfileTitle != ''">rfile_title = #{rfileTitle},</if>
            <if test="rfilePath != null and rfilePath != ''">rfile_path = #{rfilePath},</if>
            <if test="rfileType != null and rfileType != ''">rfile_type = #{rfileType},</if>
            <if test="rfileDate != null">rfile_date = #{rfileDate},</if>
        </trim>
        where rfile_id = #{rfileId}
    </update>

    <delete id="deleteSysRfileByRfileId" parameterType="Long">
        delete from sys_rfile where rfile_id = #{rfileId}
    </delete>

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