<?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.comprehensive.mapper.CphFileMapper">
    
    <resultMap type="CphFile" id="CphFileResult">
        <result property="fileName"    column="file_name"    />
        <result property="fileSrc"    column="file_src"    />
    </resultMap>

    <sql id="selectCphFileVo">
        select file_name, file_src from cph_file
    </sql>

    <select id="selectCphFileList" parameterType="CphFile" resultMap="CphFileResult">
        <include refid="selectCphFileVo"/>
        <where>  
            <if test="fileSrc != null  and fileSrc != ''"> and file_src = #{fileSrc}</if>
        </where>
    </select>
    
    <select id="selectCphFileByFileName" parameterType="String" resultMap="CphFileResult">
        <include refid="selectCphFileVo"/>
        where file_name = #{fileName}
    </select>
        
    <insert id="insertCphFile" parameterType="CphFile">
        insert into cph_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileName != null">file_name,</if>
            <if test="fileSrc != null">file_src,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileName != null">#{fileName},</if>
            <if test="fileSrc != null">#{fileSrc},</if>
         </trim>
    </insert>

    <update id="updateCphFile" parameterType="CphFile">
        update cph_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileSrc != null">file_src = #{fileSrc},</if>
        </trim>
        where file_name = #{fileName}
    </update>

    <delete id="deleteCphFileByFileName" parameterType="String">
        delete from cph_file where file_name = #{fileName}
    </delete>

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