<?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.mall.mapper.MallFeedbackMapper">
    
    <resultMap type="MallFeedback" id="MallFeedbackResult">
        <result property="id"    column="id"    />
        <result property="userId"    column="user_id"    />
        <result property="context"    column="context"    />
        <result property="status"    column="status"    />
        <result property="remark"    column="remark"    />
        <result property="createAt"    column="create_at"    />
        <result property="updateAt"    column="update_at"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="phone"    column="phone"    />
    </resultMap>

    <sql id="selectMallFeedbackVo">
        select id, user_id, context, status, remark, create_at, update_at, del_flag, phone from mall_feedback
    </sql>

    <select id="selectMallFeedbackList" parameterType="MallFeedback" resultMap="MallFeedbackResult">
        <include refid="selectMallFeedbackVo"/>
        <where>  
            <if test="status != null  and status != ''"> and status = #{status}</if>
        </where>
    </select>
    
    <select id="selectMallFeedbackById" parameterType="Long" resultMap="MallFeedbackResult">
        <include refid="selectMallFeedbackVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertMallFeedback" parameterType="MallFeedback" useGeneratedKeys="true" keyProperty="id">
        insert into mall_feedback
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="userId != null">user_id,</if>
            <if test="context != null">context,</if>
            <if test="status != null">status,</if>
            <if test="remark != null">remark,</if>
            <if test="createAt != null">create_at,</if>
            <if test="updateAt != null">update_at,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="phone != null">phone,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="userId != null">#{userId},</if>
            <if test="context != null">#{context},</if>
            <if test="status != null">#{status},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createAt != null">#{createAt},</if>
            <if test="updateAt != null">#{updateAt},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="phone != null">#{phone},</if>
         </trim>
    </insert>

    <update id="updateMallFeedback" parameterType="MallFeedback">
        update mall_feedback
        <trim prefix="SET" suffixOverrides=",">
            <if test="userId != null">user_id = #{userId},</if>
            <if test="context != null">context = #{context},</if>
            <if test="status != null">status = #{status},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createAt != null">create_at = #{createAt},</if>
            <if test="updateAt != null">update_at = #{updateAt},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="phone != null">phone = #{phone},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMallFeedbackById" parameterType="Long">
        delete from mall_feedback where id = #{id}
    </delete>

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