<?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.PosAppealMapper">
    
    <resultMap type="PosAppeal" id="PosAppealResult">
        <result property="id"    column="id"    />
        <result property="ddId"    column="dd_id"    />
        <result property="userType"    column="user_type"    />
        <result property="nickName"    column="nick_name"    />
        <result property="content"    column="content"    />
        <result property="imgs"    column="imgs"    />
        <result property="feedBack"    column="feed_back"    />
        <result property="useCase"    column="use_case"    />
    </resultMap>

    <sql id="selectPosAppealVo">
        select id, dd_id, user_type, nick_name, content, imgs,feed_back,use_case from pos_appeal
    </sql>

    <select id="selectPosAppealList" parameterType="PosAppeal" resultMap="PosAppealResult">
        <include refid="selectPosAppealVo"/>
        <where>  
            <if test="ddId != null "> and dd_id = #{ddId}</if>
            <if test="userType != null  and userType != ''"> and user_type = #{userType}</if>
        </where>
        order by dd_id asc,user_type asc,create_time desc
    </select>
    
    <select id="selectPosAppealById" parameterType="Long" resultMap="PosAppealResult">
        <include refid="selectPosAppealVo"/>
        where id = #{id}
    </select>
        
    <insert id="insertPosAppeal" parameterType="PosAppeal" useGeneratedKeys="true" keyProperty="id">
        insert into pos_appeal
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ddId != null">dd_id,</if>
            <if test="userType != null">user_type,</if>
            <if test="nickName != null">nick_name,</if>
            <if test="content != null">content,</if>
            <if test="imgs != null">imgs,</if>
            <if test="feedBack != null">feed_back,</if>
            <if test="useCase != null">use_case,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ddId != null">#{ddId},</if>
            <if test="userType != null">#{userType},</if>
            <if test="nickName != null">#{nickName},</if>
            <if test="content != null">#{content},</if>
            <if test="imgs != null">#{imgs},</if>
            <if test="feedBack != null">#{feedBack},</if>
            <if test="useCase != null">#{useCase},</if>
         </trim>
    </insert>

    <update id="updatePosAppeal" parameterType="PosAppeal">
        update pos_appeal
        <trim prefix="SET" suffixOverrides=",">
            <if test="ddId != null">dd_id = #{ddId},</if>
            <if test="userType != null">user_type = #{userType},</if>
            <if test="nickName != null">nick_name = #{nickName},</if>
            <if test="content != null">content = #{content},</if>
            <if test="imgs != null">imgs = #{imgs},</if>
            <if test="feedBack != null">feed_back = #{feedBack},</if>
            <if test="useCase != null">use_case = #{useCase},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePosAppealById" parameterType="Long">
        delete from pos_appeal where id = #{id}
    </delete>

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