<?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.ruoyi.system.mapper.SocialFeedbackMapper">
    
    <resultMap type="SocialFeedback" id="SocialFeedbackResult">
        <result property="id"    column="id"    />
        <result property="nameThe"    column="name_the"    />
        <result property="address"    column="address"    />
        <result property="contactDetails"    column="contact_details"    />
        <result property="sellersName"    column="sellers_name"    />
        <result property="feedback"    column="feedback"    />
        <result property="annexes"    column="annexes"    />
        <result property="auditStatus"    column="audit_status"    />
        <result property="feedbackTime"    column="feedback_time"    />
    </resultMap>

    <sql id="selectSocialFeedbackVo">
        select id, name_the, address, contact_details, sellers_name, feedback, annexes, audit_status, feedback_time from social_feedback
    </sql>

    <select id="selectSocialFeedbackList" parameterType="SocialFeedback" resultMap="SocialFeedbackResult">
        <include refid="selectSocialFeedbackVo"/>
        <where>  
            <if test="nameThe != null  and nameThe != ''"> and name_the = #{nameThe}</if>
            <if test="sellersName != null  and sellersName != ''"> and sellers_name like concat('%', #{sellersName}, '%')</if>
            <if test="auditStatus != null  and auditStatus != ''"> and audit_status = #{auditStatus}</if>
            <if test="feedbackTime != null "> and feedback_time = #{feedbackTime}</if>
        </where>
    </select>
    
    <select id="selectSocialFeedbackById" parameterType="Long" resultMap="SocialFeedbackResult">
        <include refid="selectSocialFeedbackVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertSocialFeedback" parameterType="SocialFeedback" useGeneratedKeys="true" keyProperty="id">
        insert into social_feedback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nameThe != null">name_the,</if>
            <if test="address != null">address,</if>
            <if test="contactDetails != null">contact_details,</if>
            <if test="sellersName != null">sellers_name,</if>
            <if test="feedback != null">feedback,</if>
            <if test="annexes != null">annexes,</if>
            <if test="auditStatus != null">audit_status,</if>
            <if test="feedbackTime != null">feedback_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="nameThe != null">#{nameThe},</if>
            <if test="address != null">#{address},</if>
            <if test="contactDetails != null">#{contactDetails},</if>
            <if test="sellersName != null">#{sellersName},</if>
            <if test="feedback != null">#{feedback},</if>
            <if test="annexes != null">#{annexes},</if>
            <if test="auditStatus != null">#{auditStatus},</if>
            <if test="feedbackTime != null">#{feedbackTime},</if>
         </trim>
    </insert>

    <update id="updateSocialFeedback" parameterType="SocialFeedback">
        update social_feedback
        <trim prefix="SET" suffixOverrides=",">
            <if test="nameThe != null">name_the = #{nameThe},</if>
            <if test="address != null">address = #{address},</if>
            <if test="contactDetails != null">contact_details = #{contactDetails},</if>
            <if test="sellersName != null">sellers_name = #{sellersName},</if>
            <if test="feedback != null">feedback = #{feedback},</if>
            <if test="annexes != null">annexes = #{annexes},</if>
            <if test="auditStatus != null">audit_status = #{auditStatus},</if>
            <if test="feedbackTime != null">feedback_time = #{feedbackTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSocialFeedbackById" parameterType="Long">
        delete from social_feedback where id = #{id}
    </delete>

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