<?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.fs.doc.mapper.DocOrderReplyMapper">
    
    <resultMap type="DocOrderReply" id="DocOrderReplyResult">
        <result property="replyId"    column="reply_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="content"    column="content"    />
        <result property="images"    column="images"    />
        <result property="video"    column="video"    />
        <result property="companyId"    column="company_id"    />
        <result property="companyUserId"    column="company_user_id"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectDocOrderReplyVo">
        select reply_id, order_id, content, images, video, company_id, company_user_id, create_time from doc_order_reply
    </sql>

    <select id="selectDocOrderReplyList" parameterType="DocOrderReply" resultMap="DocOrderReplyResult">
        <include refid="selectDocOrderReplyVo"/>
        <where>  
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="content != null  and content != ''"> and content = #{content}</if>
            <if test="images != null  and images != ''"> and images = #{images}</if>
            <if test="video != null  and video != ''"> and video = #{video}</if>
            <if test="companyId != null "> and company_id = #{companyId}</if>
            <if test="companyUserId != null "> and company_user_id = #{companyUserId}</if>
        </where>
    </select>
    
    <select id="selectDocOrderReplyById" parameterType="Long" resultMap="DocOrderReplyResult">
        <include refid="selectDocOrderReplyVo"/>
        where reply_id = #{replyId}
    </select>
        
    <insert id="insertDocOrderReply" parameterType="DocOrderReply" useGeneratedKeys="true" keyProperty="replyId">
        insert into doc_order_reply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="content != null">content,</if>
            <if test="images != null">images,</if>
            <if test="video != null">video,</if>
            <if test="companyId != null">company_id,</if>
            <if test="companyUserId != null">company_user_id,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="content != null">#{content},</if>
            <if test="images != null">#{images},</if>
            <if test="video != null">#{video},</if>
            <if test="companyId != null">#{companyId},</if>
            <if test="companyUserId != null">#{companyUserId},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateDocOrderReply" parameterType="DocOrderReply">
        update doc_order_reply
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="content != null">content = #{content},</if>
            <if test="images != null">images = #{images},</if>
            <if test="video != null">video = #{video},</if>
            <if test="companyId != null">company_id = #{companyId},</if>
            <if test="companyUserId != null">company_user_id = #{companyUserId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where reply_id = #{replyId}
    </update>

    <delete id="deleteDocOrderReplyById" parameterType="Long">
        delete from doc_order_reply where reply_id = #{replyId}
    </delete>

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