<?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.zehong.system.mapper.TOrderFeedbackMapper">
    
    <resultMap type="TOrderFeedback" id="TOrderFeedbackResult">
        <result property="feedbackId"    column="feedback_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="deviceId"    column="device_id"    />
        <result property="contents"    column="contents"    />
        <result property="feedbackTime"    column="feedback_time"    />
        <result property="isHiddenDanger"    column="is_hidden_danger"    />
        <result property="dealStatus"    column="deal_status"    />
        <result property="pictureUrl1"    column="picture_url_1"    />
        <result property="pictureUrl2"    column="picture_url_2"    />
        <result property="pictureUrl3"    column="picture_url_3"    />
    </resultMap>

    <sql id="selectTOrderFeedbackVo">
        select feedback_id, order_id, device_id, contents, feedback_time, is_hidden_danger, deal_status, picture_url_1, picture_url_2, picture_url_3 from t_order_feedback
    </sql>

    <select id="selectTOrderFeedbackList" parameterType="TOrderFeedback" resultMap="TOrderFeedbackResult">
        <include refid="selectTOrderFeedbackVo"/>
        <where>  
            <if test="orderId != null  and orderId != ''"> and order_id = #{orderId}</if>
            <if test="deviceId != null "> and device_id = #{deviceId}</if>
            <if test="contents != null  and contents != ''"> and contents = #{contents}</if>
            <if test="feedbackTime != null "> and feedback_time = #{feedbackTime}</if>
            <if test="isHiddenDanger != null  and isHiddenDanger != ''"> and is_hidden_danger = #{isHiddenDanger}</if>
            <if test="dealStatus != null  and dealStatus != ''"> and deal_status = #{dealStatus}</if>
            <if test="pictureUrl1 != null  and pictureUrl1 != ''"> and picture_url_1 = #{pictureUrl1}</if>
            <if test="pictureUrl2 != null  and pictureUrl2 != ''"> and picture_url_2 = #{pictureUrl2}</if>
            <if test="pictureUrl3 != null  and pictureUrl3 != ''"> and picture_url_3 = #{pictureUrl3}</if>
        </where>
    </select>
    
    <select id="selectTOrderFeedbackById" parameterType="int" resultMap="TOrderFeedbackResult">
        <include refid="selectTOrderFeedbackVo"/>
        where feedback_id = #{feedbackId}
    </select>

    <select id="selectTOrderFeedbackByOrderId" parameterType="String" resultMap="TOrderFeedbackResult">
        <include refid="selectTOrderFeedbackVo"/>
        where order_id = #{orderId}
        order by feedback_time desc
    </select>

    <insert id="insertTOrderFeedback" parameterType="TOrderFeedback">
        insert into t_order_feedback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="deviceId != null">device_id,</if>
            <if test="contents != null">contents,</if>
            <if test="feedbackTime != null">feedback_time,</if>
            <if test="isHiddenDanger != null">is_hidden_danger,</if>
            <if test="dealStatus != null">deal_status,</if>
            <if test="pictureUrl1 != null">picture_url_1,</if>
            <if test="pictureUrl2 != null">picture_url_2,</if>
            <if test="pictureUrl3 != null">picture_url_3,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="deviceId != null">#{deviceId},</if>
            <if test="contents != null">#{contents},</if>
            <if test="feedbackTime != null">#{feedbackTime},</if>
            <if test="isHiddenDanger != null">#{isHiddenDanger},</if>
            <if test="dealStatus != null">#{dealStatus},</if>
            <if test="pictureUrl1 != null">#{pictureUrl1},</if>
            <if test="pictureUrl2 != null">#{pictureUrl2},</if>
            <if test="pictureUrl3 != null">#{pictureUrl3},</if>
         </trim>
    </insert>

    <update id="updateTOrderFeedback" parameterType="TOrderFeedback">
        update t_order_feedback
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="deviceId != null">device_id = #{deviceId},</if>
            <if test="contents != null">contents = #{contents},</if>
            <if test="feedbackTime != null">feedback_time = #{feedbackTime},</if>
            <if test="isHiddenDanger != null">is_hidden_danger = #{isHiddenDanger},</if>
            <if test="dealStatus != null">deal_status = #{dealStatus},</if>
            <if test="pictureUrl1 != null">picture_url_1 = #{pictureUrl1},</if>
            <if test="pictureUrl2 != null">picture_url_2 = #{pictureUrl2},</if>
            <if test="pictureUrl3 != null">picture_url_3 = #{pictureUrl3},</if>
        </trim>
        where feedback_id = #{feedbackId}
    </update>

    <delete id="deleteTOrderFeedbackById" parameterType="Long">
        delete from t_order_feedback where feedback_id = #{feedbackId}
    </delete>

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