<?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.bonus.canteen.core.cook.mapper.CookEvaluaOrderMapper">
    <resultMap type="com.bonus.canteen.core.cook.domain.CookEvaluaOrder" id="CookEvaluaOrderResult">
        <result property="evaluaId"    column="evalua_id"    />
        <result property="orderId"    column="order_id"    />
        <result property="starLevel"    column="star_level"    />
        <result property="description"    column="description"    />
        <result property="reply"    column="reply"    />
        <result property="replyTime"    column="reply_time"    />
        <result property="stallId"    column="stall_id"    />
        <result property="showFlag"    column="show_flag"    />
        <result property="orderEvaluaType"    column="order_evalua_type"    />
        <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="selectCookEvaluaOrderVo">
        select evalua_id, order_id, star_level, description, reply, reply_time, stall_id, show_flag, order_evalua_type, create_by, create_time, update_by, update_time from cook_evalua_order
    </sql>

    <select id="selectCookEvaluaOrderList" parameterType="com.bonus.canteen.core.cook.domain.CookEvaluaOrder" resultMap="CookEvaluaOrderResult">
        <include refid="selectCookEvaluaOrderVo"/>
        <where>  
            <if test="orderId != null "> and order_id = #{orderId}</if>
            <if test="starLevel != null "> and star_level = #{starLevel}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="reply != null  and reply != ''"> and reply = #{reply}</if>
            <if test="replyTime != null "> and reply_time = #{replyTime}</if>
            <if test="stallId != null "> and stall_id = #{stallId}</if>
            <if test="showFlag != null "> and show_flag = #{showFlag}</if>
            <if test="orderEvaluaType != null "> and order_evalua_type = #{orderEvaluaType}</if>
        </where>
    </select>
    
    <select id="selectCookEvaluaOrderByEvaluaId" parameterType="Long" resultMap="CookEvaluaOrderResult">
        <include refid="selectCookEvaluaOrderVo"/>
        where evalua_id = #{evaluaId}
    </select>
        
    <insert id="insertCookEvaluaOrder" parameterType="com.bonus.canteen.core.cook.domain.CookEvaluaOrder" useGeneratedKeys="true" keyProperty="evaluaId">
        insert into cook_evalua_order
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="orderId != null">order_id,</if>
            <if test="starLevel != null">star_level,</if>
            <if test="description != null and description != ''">description,</if>
            <if test="reply != null">reply,</if>
            <if test="replyTime != null">reply_time,</if>
            <if test="stallId != null">stall_id,</if>
            <if test="showFlag != null">show_flag,</if>
            <if test="orderEvaluaType != null">order_evalua_type,</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="orderId != null">#{orderId},</if>
            <if test="starLevel != null">#{starLevel},</if>
            <if test="description != null and description != ''">#{description},</if>
            <if test="reply != null">#{reply},</if>
            <if test="replyTime != null">#{replyTime},</if>
            <if test="stallId != null">#{stallId},</if>
            <if test="showFlag != null">#{showFlag},</if>
            <if test="orderEvaluaType != null">#{orderEvaluaType},</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="updateCookEvaluaOrder" parameterType="com.bonus.canteen.core.cook.domain.CookEvaluaOrder">
        update cook_evalua_order
        <trim prefix="SET" suffixOverrides=",">
            <if test="orderId != null">order_id = #{orderId},</if>
            <if test="starLevel != null">star_level = #{starLevel},</if>
            <if test="description != null and description != ''">description = #{description},</if>
            <if test="reply != null">reply = #{reply},</if>
            <if test="replyTime != null">reply_time = #{replyTime},</if>
            <if test="stallId != null">stall_id = #{stallId},</if>
            <if test="showFlag != null">show_flag = #{showFlag},</if>
            <if test="orderEvaluaType != null">order_evalua_type = #{orderEvaluaType},</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 evalua_id = #{evaluaId}
    </update>

    <delete id="deleteCookEvaluaOrderByEvaluaId" parameterType="Long">
        delete from cook_evalua_order where evalua_id = #{evaluaId}
    </delete>

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