<?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.supervision.thought.mapper.ThoughtPlanResponsefuMapper">
    
    <resultMap type="ThoughtPlanResponsefu" id="ThoughtPlanResponsefuResult">
        <result property="id"    column="id"    />
        <result property="planId"    column="plan_id"    />
        <result property="fileName"    column="file_name"    />
        <result property="filePath"    column="file_path"    />
    </resultMap>

    <sql id="selectThoughtPlanResponsefuVo">
        select id, plan_id, file_name, file_path from thought_plan_responsefu
    </sql>

    <select id="selectThoughtPlanResponsefuList" parameterType="ThoughtPlanResponsefu" resultMap="ThoughtPlanResponsefuResult">
        <include refid="selectThoughtPlanResponsefuVo"/>
        <where>  
            <if test="planId != null "> and plan_id = #{planId}</if>
            <if test="fileName != null  and fileName != ''"> and file_name like concat('%', #{fileName}, '%')</if>
            <if test="filePath != null  and filePath != ''"> and file_path = #{filePath}</if>
        </where>
    </select>
    
    <select id="selectThoughtPlanResponsefuById" parameterType="Long" resultMap="ThoughtPlanResponsefuResult">
        <include refid="selectThoughtPlanResponsefuVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertThoughtPlanResponsefu" parameterType="ThoughtPlanResponsefu" useGeneratedKeys="true" keyProperty="id">
        insert into thought_plan_responsefu
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="planId != null">plan_id,</if>
            <if test="fileName != null">file_name,</if>
            <if test="filePath != null">file_path,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="planId != null">#{planId},</if>
            <if test="fileName != null">#{fileName},</if>
            <if test="filePath != null">#{filePath},</if>
         </trim>
    </insert>

    <update id="updateThoughtPlanResponsefu" parameterType="ThoughtPlanResponsefu">
        update thought_plan_responsefu
        <trim prefix="SET" suffixOverrides=",">
            <if test="planId != null">plan_id = #{planId},</if>
            <if test="fileName != null">file_name = #{fileName},</if>
            <if test="filePath != null">file_path = #{filePath},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteThoughtPlanResponsefuById" parameterType="Long">
        delete from thought_plan_responsefu where id = #{id}
    </delete>

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