<?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.PosOrderRatingMapper">

    <resultMap type="PosOrderRating" id="PosOrderRatingResult">
        <result property="id"    column="id"    />
        <result property="ddId"    column="dd_id"    />
        <result property="userId"    column="user_id"    />
        <result property="qsId"    column="qs_id"    />
        <result property="qsStars"    column="qs_stars"    />
        <result property="qsComment"    column="qs_comment"    />
        <result property="qsImage"    column="qs_image"    />
        <result property="mdId"    column="md_id"    />
        <result property="mdStars"    column="md_stars"    />
        <result property="mdComment"    column="md_comment"    />
        <result property="mdImage"    column="md_image"    />
        <result property="createTime"    column="create_time"    />
    </resultMap>

    <sql id="selectPosOrderRatingVo">
        select id, dd_id, user_id, qs_id, qs_stars, qs_comment, qs_image, md_id, md_stars, md_comment, md_image, create_time from pos_order_rating
    </sql>

    <select id="selectPosOrderRatingList" parameterType="PosOrderRating" resultMap="PosOrderRatingResult">
        <include refid="selectPosOrderRatingVo"/>
        <where>
            <if test="ddId != null "> and dd_id = #{ddId}</if>
            <if test="userId != null "> and user_id = #{userId}</if>
            <if test="qsId != null "> and qs_id = #{qsId}</if>
            <if test="qsStars != null  and qsStars != ''"> and qs_stars = #{qsStars}</if>
            <if test="qsComment != null  and qsComment != ''"> and qs_comment = #{qsComment}</if>
            <if test="qsImage != null  and qsImage != ''"> and qs_image = #{qsImage}</if>
            <if test="mdId != null "> and md_id = #{mdId}</if>
            <if test="mdStars != null  and mdStars != ''"> and md_stars = #{mdStars}</if>
            <if test="mdComment != null  and mdComment != ''"> and md_comment = #{mdComment}</if>
            <if test="mdImage != null  and mdImage != ''"> and md_image = #{mdImage}</if>
        </where>
    </select>

    <select id="selectPosOrderRatingById" parameterType="Long" resultMap="PosOrderRatingResult">
        <include refid="selectPosOrderRatingVo"/>
        where id = #{id}
    </select>

    <insert id="insertPosOrderRating" parameterType="PosOrderRating" useGeneratedKeys="true" keyProperty="id">
        insert into pos_order_rating
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="ddId != null">dd_id,</if>
            <if test="userId != null">user_id,</if>
            <if test="qsId != null">qs_id,</if>
            <if test="qsStars != null">qs_stars,</if>
            <if test="qsComment != null">qs_comment,</if>
            <if test="qsImage != null">qs_image,</if>
            <if test="mdId != null">md_id,</if>
            <if test="mdStars != null">md_stars,</if>
            <if test="mdComment != null">md_comment,</if>
            <if test="mdImage != null">md_image,</if>
            <if test="createTime != null">create_time,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="ddId != null">#{ddId},</if>
            <if test="userId != null">#{userId},</if>
            <if test="qsId != null">#{qsId},</if>
            <if test="qsStars != null">#{qsStars},</if>
            <if test="qsComment != null">#{qsComment},</if>
            <if test="qsImage != null">#{qsImage},</if>
            <if test="mdId != null">#{mdId},</if>
            <if test="mdStars != null">#{mdStars},</if>
            <if test="mdComment != null">#{mdComment},</if>
            <if test="mdImage != null">#{mdImage},</if>
            <if test="createTime != null">#{createTime},</if>
        </trim>
    </insert>

    <update id="updatePosOrderRating" parameterType="PosOrderRating">
        update pos_order_rating
        <trim prefix="SET" suffixOverrides=",">
            <if test="ddId != null">dd_id = #{ddId},</if>
            <if test="userId != null">user_id = #{userId},</if>
            <if test="qsId != null">qs_id = #{qsId},</if>
            <if test="qsStars != null">qs_stars = #{qsStars},</if>
            <if test="qsComment != null">qs_comment = #{qsComment},</if>
            <if test="qsImage != null">qs_image = #{qsImage},</if>
            <if test="mdId != null">md_id = #{mdId},</if>
            <if test="mdStars != null">md_stars = #{mdStars},</if>
            <if test="mdComment != null">md_comment = #{mdComment},</if>
            <if test="mdImage != null">md_image = #{mdImage},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deletePosOrderRatingById" parameterType="Long">
        delete from pos_order_rating where id = #{id}
    </delete>

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