<?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.ThoughtPlanFuMapper">
    
    <resultMap type="ThoughtPlanFu" id="ThoughtPlanFuResult">
        <result property="id"    column="id"    />
        <result property="planId"    column="plan_id"    />
        <result property="planContent"    column="plan_content"    />
        <result property="isresponse"    column="isresponse"    />
    </resultMap>

    <sql id="selectThoughtPlanFuVo">
        select id, plan_id, plan_content, isresponse from thought_plan_fu
    </sql>

    <select id="selectThoughtPlanFuList" parameterType="ThoughtPlanFu" resultMap="ThoughtPlanFuResult">
        <include refid="selectThoughtPlanFuVo"/>
        <where>  
            <if test="planId != null "> and plan_id = #{planId}</if>
            <if test="planContent != null  and planContent != ''"> and plan_content = #{planContent}</if>
            <if test="isresponse != null  and isresponse != ''"> and isresponse = #{isresponse}</if>
        </where>
    </select>
    
    <select id="selectThoughtPlanFuById" parameterType="Long" resultMap="ThoughtPlanFuResult">
        <include refid="selectThoughtPlanFuVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertThoughtPlanFu" parameterType="ThoughtPlanFu" useGeneratedKeys="true" keyProperty="id">
        insert into thought_plan_fu
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="planId != null">plan_id,</if>
            <if test="planContent != null">plan_content,</if>
            <if test="isresponse != null">isresponse,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="planId != null">#{planId},</if>
            <if test="planContent != null">#{planContent},</if>
            <if test="isresponse != null">#{isresponse},</if>
         </trim>
    </insert>

    <update id="updateThoughtPlanFu" parameterType="ThoughtPlanFu">
        update thought_plan_fu
        <trim prefix="SET" suffixOverrides=",">
            <if test="planId != null">plan_id = #{planId},</if>
            <if test="planContent != null">plan_content = #{planContent},</if>
            <if test="isresponse != null">isresponse = #{isresponse},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteThoughtPlanFuById" parameterType="Long">
        delete from thought_plan_fu where id = #{id}
    </delete>

    <delete id="deleteThoughtPlanFuByIds" parameterType="String">
        delete from thought_plan_fu where id in 
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
    <delete id="deleteThoughtPlanFuBy">
        delete from thought_plan_fu where plan_id = #{planId}
    </delete>
</mapper>