<?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.store.mapper.FsStoreProductReplyMapper">
    
    <resultMap type="FsStoreProductReply" id="FsStoreProductReplyResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="productId"    column="product_id"    />
        <result property="replyType"    column="reply_type"    />
        <result property="productScore"    column="product_score"    />
        <result property="serviceScore"    column="service_score"    />
        <result property="comment"    column="comment"    />
        <result property="pics"    column="pics"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateTime"    column="update_time"    />
        <result property="replyContent"    column="reply_content"    />
        <result property="replyTime"    column="reply_time"    />
        <result property="isDel"    column="is_del"    />
        <result property="isReply"    column="is_reply"    />
    </resultMap>

    <sql id="selectFsStoreProductReplyVo">
        select id, user_id, order_id, product_id, reply_type, product_score, service_score, comment, pics, create_time, update_time, reply_content, reply_time, is_del, is_reply from fs_store_product_reply
    </sql>

    <select id="selectFsStoreProductReplyList" parameterType="FsStoreProductReply" resultMap="FsStoreProductReplyResult">
        <include refid="selectFsStoreProductReplyVo"/>
        <where>  
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="productId != null "> and product_id = #{productId}</if>
            <if test="replyType != null  and replyType != ''"> and reply_type = #{replyType}</if>
            <if test="productScore != null "> and product_score = #{productScore}</if>
            <if test="serviceScore != null "> and service_score = #{serviceScore}</if>
            <if test="comment != null  and comment != ''"> and comment = #{comment}</if>
            <if test="pics != null  and pics != ''"> and pics = #{pics}</if>
            <if test="replyContent != null  and replyContent != ''"> and reply_content = #{merchantReplyContent}</if>
            <if test="replyTime != null "> and reply_time = #{replyTime}</if>
            <if test="isDel != null "> and is_del = #{isDel}</if>
            <if test="isReply != null "> and is_reply = #{isReply}</if>
        </where>
    </select>
    
    <select id="selectFsStoreProductReplyById" parameterType="Long" resultMap="FsStoreProductReplyResult">
        <include refid="selectFsStoreProductReplyVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertFsStoreProductReply" parameterType="FsStoreProductReply" useGeneratedKeys="true" keyProperty="id">
        insert into fs_store_product_reply
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="orderId != null">order_id,</if>
            <if test="productId != null">product_id,</if>
            <if test="replyType != null and replyType != ''">reply_type,</if>
            <if test="productScore != null">product_score,</if>
            <if test="serviceScore != null">service_score,</if>
            <if test="comment != null and comment != ''">comment,</if>
            <if test="pics != null and pics != ''">pics,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="replyContent != null">reply_content,</if>
            <if test="replyTime != null">reply_time,</if>
            <if test="isDel != null">is_del,</if>
            <if test="isReply != null">is_reply,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="orderId != null">#{orderId},</if>
            <if test="productId != null">#{productId},</if>
            <if test="replyType != null and replyType != ''">#{replyType},</if>
            <if test="productScore != null">#{productScore},</if>
            <if test="serviceScore != null">#{serviceScore},</if>
            <if test="comment != null and comment != ''">#{comment},</if>
            <if test="pics != null and pics != ''">#{pics},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="replyContent != null">#{replyContent},</if>
            <if test="replyTime != null">#{replyTime},</if>
            <if test="isDel != null">#{isDel},</if>
            <if test="isReply != null">#{isReply},</if>
         </trim>
    </insert>

    <update id="updateFsStoreProductReply" parameterType="FsStoreProductReply">
        update fs_store_product_reply
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="productId != null">product_id = #{productId},</if>
            <if test="replyType != null and replyType != ''">reply_type = #{replyType},</if>
            <if test="productScore != null">product_score = #{productScore},</if>
            <if test="serviceScore != null">service_score = #{serviceScore},</if>
            <if test="comment != null and comment != ''">comment = #{comment},</if>
            <if test="pics != null and pics != ''">pics = #{pics},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="replyContent != null">reply_content = #{replyContent},</if>
            <if test="replyTime != null">reply_time = #{replyTime},</if>
            <if test="isDel != null">is_del = #{isDel},</if>
            <if test="isReply != null">is_reply = #{isReply},</if>
        </trim>
        where id = #{id}
    </update>

    <update id="deleteFsStoreProductReplyById" parameterType="Long">
        update fs_store_product_reply set is_del=1 where id = #{id}
    </update>

    <update id="deleteFsStoreProductReplyByIds" parameterType="String">
        update fs_store_product_reply set is_del=1 where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </update>
    
</mapper>