<?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.supplier.mapper.TCanteenRatingMapper">
    
    <resultMap type="TCanteenRating" id="TCanteenRatingResult">
        <result property="rateId"    column="rate_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="menuId"    column="menu_id"    />
        <result property="score"    column="score"    />
        <result property="comment"    column="comment"    />
        <result property="rateTime"    column="rate_time"    />
        <result property="status"    column="status"    />
        <result property="delFlag"    column="del_flag"    />
        <result property="createrCode"    column="creater_code"    />
        <result property="createdate"    column="createdate"    />
        <result property="updaterCode"    column="updater_code"    />
        <result property="updatedate"    column="updatedate"    />
        <result property="deptId"    column="dept_id"    />
        <result property="remarks"    column="remarks"    />
    </resultMap>

    <sql id="selectTCanteenRatingVo">
        select rate_id, order_id, menu_id, score, comment, rate_time, status, del_flag, creater_code, createdate, updater_code, updatedate, dept_id, remarks from t_canteen_rating
    </sql>

    <select id="selectTCanteenRatingList" parameterType="TCanteenRating" resultMap="TCanteenRatingResult">
        <include refid="selectTCanteenRatingVo"/>
        <where>  
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="menuId != null "> and menu_id = #{menuId}</if>
            <if test="score != null  and score != ''"> and score = #{score}</if>
            <if test="comment != null  and comment != ''"> and comment = #{comment}</if>
            <if test="rateTime != null "> and rate_time = #{rateTime}</if>
            <if test="status != null "> and status = #{status}</if>
            <if test="createrCode != null "> and creater_code = #{createrCode}</if>
            <if test="createdate != null "> and createdate = #{createdate}</if>
            <if test="updaterCode != null "> and updater_code = #{updaterCode}</if>
            <if test="updatedate != null "> and updatedate = #{updatedate}</if>
            <if test="deptId != null "> and dept_id = #{deptId}</if>
            <if test="remarks != null  and remarks != ''"> and remarks = #{remarks}</if>
        </where>
    </select>
    
    <select id="selectTCanteenRatingByRateId" parameterType="Long" resultMap="TCanteenRatingResult">
        <include refid="selectTCanteenRatingVo"/>
        where rate_id = #{rateId}
    </select>

    <insert id="insertTCanteenRating" parameterType="TCanteenRating" useGeneratedKeys="true" keyProperty="rateId">
        insert into t_canteen_rating
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="menuId != null">menu_id,</if>
            <if test="score != null and score != ''">score,</if>
            <if test="comment != null and comment != ''">comment,</if>
            <if test="rateTime != null">rate_time,</if>
            <if test="status != null">status,</if>
            <if test="delFlag != null">del_flag,</if>
            <if test="createrCode != null">creater_code,</if>
            <if test="createdate != null">createdate,</if>
            <if test="updaterCode != null">updater_code,</if>
            <if test="updatedate != null">updatedate,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="remarks != null">remarks,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="orderId != null">#{orderId},</if>
            <if test="menuId != null">#{menuId},</if>
            <if test="score != null and score != ''">#{score},</if>
            <if test="comment != null and comment != ''">#{comment},</if>
            <if test="rateTime != null">#{rateTime},</if>
            <if test="status != null">#{status},</if>
            <if test="delFlag != null">#{delFlag},</if>
            <if test="createrCode != null">#{createrCode},</if>
            <if test="createdate != null">#{createdate},</if>
            <if test="updaterCode != null">#{updaterCode},</if>
            <if test="updatedate != null">#{updatedate},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="remarks != null">#{remarks},</if>
         </trim>
    </insert>

    <update id="updateTCanteenRating" parameterType="TCanteenRating">
        update t_canteen_rating
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="menuId != null">menu_id = #{menuId},</if>
            <if test="score != null and score != ''">score = #{score},</if>
            <if test="comment != null and comment != ''">comment = #{comment},</if>
            <if test="rateTime != null">rate_time = #{rateTime},</if>
            <if test="status != null">status = #{status},</if>
            <if test="delFlag != null">del_flag = #{delFlag},</if>
            <if test="createrCode != null">creater_code = #{createrCode},</if>
            <if test="createdate != null">createdate = #{createdate},</if>
            <if test="updaterCode != null">updater_code = #{updaterCode},</if>
            <if test="updatedate != null">updatedate = #{updatedate},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="remarks != null">remarks = #{remarks},</if>
        </trim>
        where rate_id = #{rateId}
    </update>

    <delete id="deleteTCanteenRatingByRateId" parameterType="Long">
        delete from t_canteen_rating where rate_id = #{rateId}
    </delete>

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