<?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.menu.mapper.MenuEvaluaDetailMapper">
    <resultMap type="com.bonus.canteen.core.menu.domain.MenuEvaluaDetail" id="MenuEvaluaDetailResult">
        <result property="detailId"    column="detail_id"    />
        <result property="evaluaId"    column="evalua_id"    />
        <result property="mealType"    column="meal_type"    />
        <result property="mealId"    column="meal_id"    />
        <result property="starLevel"    column="star_level"    />
        <result property="description"    column="description"    />
        <result property="revision"    column="revision"    />
        <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="selectMenuEvaluaDetailVo">
        select detail_id, evalua_id, meal_type, meal_id, star_level, description,
               revision, create_by, create_time, update_by, update_time
        from menu_evalua_detail
    </sql>

    <select id="selectMenuEvaluaDetailList" parameterType="com.bonus.canteen.core.menu.domain.MenuEvaluaDetail" resultMap="MenuEvaluaDetailResult">
        <include refid="selectMenuEvaluaDetailVo"/>
        <where>  
            <if test="detailId != null "> and detail_id = #{detailId}</if>
            <if test="evaluaId != null "> and evalua_id = #{evaluaId}</if>
            <if test="mealType != null "> and meal_type = #{mealType}</if>
            <if test="mealId != null "> and meal_id = #{mealId}</if>
            <if test="starLevel != null "> and star_level = #{starLevel}</if>
            <if test="description != null  and description != ''"> and description = #{description}</if>
            <if test="revision != null "> and revision = #{revision}</if>
        </where>
    </select>
    
    <select id="selectMenuEvaluaDetailById" parameterType="Long" resultMap="MenuEvaluaDetailResult">
        <include refid="selectMenuEvaluaDetailVo"/>
        where detail_id = #{detailId}
    </select>
        
    <insert id="insertMenuEvaluaDetail" parameterType="com.bonus.canteen.core.menu.domain.MenuEvaluaDetail" useGeneratedKeys="true" keyProperty="detailId">
        insert into menu_evalua_detail
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="evaluaId != null">evalua_id,</if>
            <if test="mealType != null">meal_type,</if>
            <if test="mealId != null">meal_id,</if>
            <if test="starLevel != null">star_level,</if>
            <if test="description != null and description != ''">description,</if>
            <if test="revision != null">revision,</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="evaluaId != null">#{evaluaId},</if>
            <if test="mealType != null">#{mealType},</if>
            <if test="mealId != null">#{mealId},</if>
            <if test="starLevel != null">#{starLevel},</if>
            <if test="description != null and description != ''">#{description},</if>
            <if test="revision != null">#{revision},</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="updateMenuEvaluaDetail" parameterType="com.bonus.canteen.core.menu.domain.MenuEvaluaDetail">
        update menu_evalua_detail
        <trim prefix="SET" suffixOverrides=",">
            <if test="evaluaId != null">evalua_id = #{evaluaId},</if>
            <if test="mealType != null">meal_type = #{mealType},</if>
            <if test="mealId != null">meal_id = #{mealId},</if>
            <if test="starLevel != null">star_level = #{starLevel},</if>
            <if test="description != null and description != ''">description = #{description},</if>
            <if test="revision != null">revision = #{revision},</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 detail_id = #{detailId}
    </update>

    <delete id="deleteMenuEvaluaDetailById" parameterType="Long">
        delete from menu_evalua_detail where detail_id = #{detailId}
    </delete>

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