<?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.model.mapper.AppletCommentMapper">
    
    <resultMap type="AppletComment" id="AppletCommentResult">
        <result property="id"    column="id"    />
        <result property="comment"    column="comment"    />
        <result property="satisfaction"    column="satisfaction"    />
        <result property="user1Id"    column="user1_id"    />
        <result property="user2Id"    column="user2_id"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createBy"    column="create_by"    />
        <result property="createTime"    column="create_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="updateTime"    column="update_time"    />
    </resultMap>

    <sql id="selectAppletCommentVo">
        select id, comment, satisfaction, user1_id, user2_id, del_flag, create_by, create_time, update_by, update_time from applet_comment
    </sql>

    <select id="selectAppletCommentList" parameterType="AppletComment" resultMap="AppletCommentResult">
        <include refid="selectAppletCommentVo"/>
        <where>  
            <if test="comment != null  and comment != ''"> and comment = #{comment}</if>
            <if test="satisfaction != null "> and satisfaction = #{satisfaction}</if>
            <if test="user1Id != null "> and user1_id = #{user1Id}</if>
            <if test="user2Id != null "> and user2_id = #{user2Id}</if>
        </where>
    </select>
    
    <select id="selectAppletCommentById" parameterType="AppletComment" resultMap="AppletCommentResult">
        <include refid="selectAppletCommentVo"/>
        where id = #{id}
    </select>

    <insert id="insertAppletComment" parameterType="AppletComment" useGeneratedKeys="true" keyProperty="id">
        insert into applet_comment
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="comment != null and comment != ''">comment,</if>
            <if test="satisfaction != null">satisfaction,</if>
            <if test="user1Id != null">user1_id,</if>
            <if test="user2Id != null">user2_id,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createBy != null">create_by,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateBy != null">update_by,</if>
            <if test="updateTime != null">update_time,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="comment != null and comment != ''">#{comment},</if>
            <if test="satisfaction != null">#{satisfaction},</if>
            <if test="user1Id != null">#{user1Id},</if>
            <if test="user2Id != null">#{user2Id},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createBy != null">#{createBy},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateBy != null">#{updateBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
         </trim>
    </insert>

    <update id="updateAppletComment" parameterType="AppletComment">
        update applet_comment
        <trim prefix="SET" suffixOverrides=",">
            <if test="comment != null and comment != ''">comment = #{comment},</if>
            <if test="satisfaction != null">satisfaction = #{satisfaction},</if>
            <if test="user1Id != null">user1_id = #{user1Id},</if>
            <if test="user2Id != null">user2_id = #{user2Id},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createBy != null">create_by = #{createBy},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteAppletCommentById" parameterType="Long">
        delete from applet_comment where id = #{id}
    </delete>

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