<?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.ruoyi.system.mapper.PoNewsFileMapper">

    <resultMap type="PoNewsFile" id="PoNewsFileResult">
        <result property="fileId"    column="file_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="image"    column="image"    />
        <result property="filePath"    column="file_path"    />
    </resultMap>

    <sql id="selectPoNewsFileVo">
        select file_id, file_name, image, file_path from po_news_file
    </sql>

    <select id="selectPoNewsFileList" parameterType="PoNewsFile" resultMap="PoNewsFileResult">
        <include refid="selectPoNewsFileVo"/>
        <where>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="image != null  and image != ''"> and image = #{image}</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
        </where>
    </select>

    <select id="selectPoNewsFileByFileId" parameterType="Long" resultMap="PoNewsFileResult">
        <include refid="selectPoNewsFileVo"/>
        where file_id = #{fileId}
    </select>

    <insert id="insertPoNewsFile" parameterType="PoNewsFile">
        insert into po_news_file
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="fileId != null">file_id,</if>
            <if test="fileName != null and fileName != ''">file_name,</if>
            <if test="image != null and image != ''">image,</if>
            <if test="filePath != null">file_path,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="fileId != null">#{fileId},</if>
            <if test="fileName != null and fileName != ''">#{fileName},</if>
            <if test="image != null and image != ''">#{image},</if>
            <if test="filePath != null">#{filePath},</if>
        </trim>
    </insert>

    <update id="updatePoNewsFile" parameterType="PoNewsFile">
        update po_news_file
        <trim prefix="SET" suffixOverrides=",">
            <if test="fileName != null and fileName != ''">file_name = #{fileName},</if>
            <if test="image != null and image != ''">image = #{image},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
        </trim>
        where file_id = #{fileId}
    </update>

    <delete id="deletePoNewsFileByFileId" parameterType="Long">
        delete from po_news_file where file_id = #{fileId}
    </delete>

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