<?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.ss.feedback.mapper.FeedbackMapper">

    <resultMap type="Feedback" id="AsFeedbackResult" autoMapping="true" />

    <sql id="selectAsFeedbackVo">
        select feedback_id, type, issue_description, uploaded_image, contact_info, create_by, create_time from ss_feedback
    </sql>

    <select id="selectAsFeedbackList" parameterType="Feedback" resultMap="AsFeedbackResult">
        <include refid="selectAsFeedbackVo"/>
        <where>
            <if test="type != null  and type != ''"> and type = #{type}</if>
            <if test="contactInfo != null  and contactInfo != ''"> and contact_info = #{contactInfo}</if>
            <if test="createBy != null  and createBy != ''"> and create_by = #{createBy}</if>
        </where>
    </select>

    <select id="selectAsFeedbackByFeedbackId" parameterType="Long" resultMap="AsFeedbackResult">
        <include refid="selectAsFeedbackVo"/>
        where feedback_id = #{feedbackId}
    </select>

    <insert id="insertAsFeedback" parameterType="Feedback" useGeneratedKeys="true" keyProperty="feedbackId">
        insert into ss_feedback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="type != null and type != ''">type,</if>
            <if test="issueDescription != null and issueDescription != ''">issue_description,</if>
            <if test="uploadedImage != null">uploaded_image,</if>
            <if test="contactInfo != null">contact_info,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="createTime != null">create_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="type != null and type != ''">#{type},</if>
            <if test="issueDescription != null and issueDescription != ''">#{issueDescription},</if>
            <if test="uploadedImage != null">#{uploadedImage},</if>
            <if test="contactInfo != null">#{contactInfo},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
         </trim>
    </insert>

    <update id="updateAsFeedback" parameterType="Feedback">
        update ss_feedback
        <trim prefix="SET" suffixOverrides=",">
            <if test="type != null and type != ''">type = #{type},</if>
            <if test="issueDescription != null and issueDescription != ''">issue_description = #{issueDescription},</if>
            <if test="uploadedImage != null">uploaded_image = #{uploadedImage},</if>
            <if test="contactInfo != null">contact_info = #{contactInfo},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where feedback_id = #{feedbackId}
    </update>

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

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