<?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.MenuDishesMapper">
    <resultMap type="com.bonus.canteen.core.menu.domain.MenuDishes" id="MenuDishesResult">
        <result property="id"    column="id"    />
        <result property="dishesId"    column="dishes_id"    />
        <result property="baseDishesId"    column="base_dishes_id"    />
        <result property="mealType"    column="meal_type"    />
        <result property="dishesNum"    column="dishes_num"    />
        <result property="customId"    column="custom_id"    />
        <result property="inventoryId"    column="inventory_id"    />
        <result property="dishesName"    column="dishes_name"    />
        <result property="aliasName"    column="alias_name"    />
        <result property="pinyinInitials"    column="pinyin_initials"    />
        <result property="pinyinFull"    column="pinyin_full"    />
        <result property="barCode"    column="bar_code"    />
        <result property="intro"    column="intro"    />
        <result property="cookId"    column="cook_id"    />
        <result property="typeId"    column="type_id"    />
        <result property="classifyId"    column="classify_id"    />
        <result property="effectId"    column="effect_id"    />
        <result property="styleId"    column="style_id"    />
        <result property="ifLocalFeature"    column="if_local_feature"    />
        <result property="dishesDepart"    column="dishes_depart"    />
        <result property="sequence"    column="sequence"    />
        <result property="pungencyDegree"    column="pungency_degree"    />
        <result property="salesMode"    column="sales_mode"    />
        <result property="sizeType"    column="size_type"    />
        <result property="sizeJson"    column="size_json"    />
        <result property="weight"    column="weight"    />
        <result property="largeWeight"    column="large_weight"    />
        <result property="littleWeight"    column="little_weight"    />
        <result property="weightDeviation"    column="weight_deviation"    />
        <result property="price"    column="price"    />
        <result property="unitPrice"    column="unit_price"    />
        <result property="largePrice"    column="large_price"    />
        <result property="littlePrice"    column="little_price"    />
        <result property="imageUrl"    column="image_url"    />
        <result property="particulars"    column="particulars"    />
        <result property="recommend"    column="recommend"    />
        <result property="indexRecommend"    column="index_recommend"    />
        <result property="likeSurvey"    column="like_survey"    />
        <result property="likeBatch"    column="like_batch"    />
        <result property="likeNum"    column="like_num"    />
        <result property="initialScore"    column="initial_score"    />
        <result property="calories"    column="calories"    />
        <result property="protein"    column="protein"    />
        <result property="fat"    column="fat"    />
        <result property="carbohydrate"    column="carbohydrate"    />
        <result property="dietaryFiber"    column="dietary_fiber"    />
        <result property="cholesterol"    column="cholesterol"    />
        <result property="calcium"    column="calcium"    />
        <result property="sodium"    column="sodium"    />
        <result property="purine"    column="purine"    />
        <result property="iron"    column="iron"    />
        <result property="iodine"    column="iodine"    />
        <result property="kalium"    column="kalium"    />
        <result property="vitaminA"    column="vitamin_a"    />
        <result property="vitaminC"    column="vitamin_c"    />
        <result property="vitaminE"    column="vitamin_e"    />
        <result property="magnesium"    column="magnesium"    />
        <result property="zinc"    column="zinc"    />
        <result property="glycemicIndex"    column="glycemic_index"    />
        <result property="sort"    column="sort"    />
        <result property="canteenId"    column="canteen_id"    />
        <result property="shopstallId"    column="shopstall_id"    />
        <result property="hideFlag"    column="hide_flag"    />
        <result property="convertFlag"    column="convert_flag"    />
        <result property="materialCost"    column="material_cost"    />
        <result property="grossProfit"    column="gross_profit"    />
        <result property="grossProfitRate"    column="gross_profit_rate"    />
        <result property="publicDishes"    column="public_dishes"    />
        <result property="areaId"    column="area_id"    />
        <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"    />
        <result property="remark"    column="remark"    />
    </resultMap>

    <sql id="selectMenuDishesVo">
        select id, dishes_id, base_dishes_id, meal_type, dishes_num, custom_id, inventory_id, dishes_name, alias_name, pinyin_initials, pinyin_full, bar_code, intro, cook_id, type_id, classify_id, effect_id, style_id, if_local_feature, dishes_depart, sequence, pungency_degree, sales_mode, size_type, size_json, weight, large_weight, little_weight, weight_deviation, price, unit_price, large_price, little_price, image_url, particulars, recommend, index_recommend, like_survey, like_batch, like_num, initial_score, calories, protein, fat, carbohydrate, dietary_fiber, cholesterol, calcium, sodium, purine, iron, iodine, kalium, vitamin_a, vitamin_c, vitamin_e, magnesium, zinc, glycemic_index, sort, canteen_id, shopstall_id, hide_flag, convert_flag, material_cost, gross_profit, gross_profit_rate, public_dishes, area_id, revision, create_by, create_time, update_by, update_time, remark from menu_dishes
    </sql>

    <select id="selectMenuDishesList" parameterType="com.bonus.canteen.core.menu.domain.MenuDishes" resultMap="MenuDishesResult">
        <include refid="selectMenuDishesVo"/>
        <where>
            <if test="dishesId != null "> and dishes_id = #{dishesId}</if>
            <if test="baseDishesId != null "> and base_dishes_id = #{baseDishesId}</if>
            <if test="mealType != null "> and meal_type = #{mealType}</if>
            <if test="dishesNum != null  and dishesNum != ''"> and dishes_num = #{dishesNum}</if>
            <if test="customId != null "> and custom_id = #{customId}</if>
            <if test="inventoryId != null  and inventoryId != ''"> and inventory_id = #{inventoryId}</if>
            <if test="dishesName != null  and dishesName != ''"> and dishes_name like concat('%', #{dishesName}, '%')</if>
            <if test="aliasName != null  and aliasName != ''"> and alias_name like concat('%', #{aliasName}, '%')</if>
            <if test="pinyinInitials != null  and pinyinInitials != ''"> and pinyin_initials = #{pinyinInitials}</if>
            <if test="pinyinFull != null  and pinyinFull != ''"> and pinyin_full = #{pinyinFull}</if>
            <if test="barCode != null  and barCode != ''"> and bar_code = #{barCode}</if>
            <if test="intro != null  and intro != ''"> and intro = #{intro}</if>
            <if test="cookId != null "> and cook_id = #{cookId}</if>
            <if test="typeId != null "> and type_id = #{typeId}</if>
            <if test="classifyId != null "> and classify_id = #{classifyId}</if>
            <if test="effectId != null "> and effect_id = #{effectId}</if>
            <if test="styleId != null "> and style_id = #{styleId}</if>
            <if test="ifLocalFeature != null "> and if_local_feature = #{ifLocalFeature}</if>
            <if test="dishesDepart != null "> and dishes_depart = #{dishesDepart}</if>
            <if test="sequence != null "> and sequence = #{sequence}</if>
            <if test="pungencyDegree != null "> and pungency_degree = #{pungencyDegree}</if>
            <if test="salesMode != null "> and sales_mode = #{salesMode}</if>
            <if test="sizeType != null "> and size_type = #{sizeType}</if>
            <if test="sizeJson != null  and sizeJson != ''"> and size_json = #{sizeJson}</if>
            <if test="weight != null "> and weight = #{weight}</if>
            <if test="largeWeight != null "> and large_weight = #{largeWeight}</if>
            <if test="littleWeight != null "> and little_weight = #{littleWeight}</if>
            <if test="weightDeviation != null "> and weight_deviation = #{weightDeviation}</if>
            <if test="price != null "> and price = #{price}</if>
            <if test="unitPrice != null "> and unit_price = #{unitPrice}</if>
            <if test="largePrice != null "> and large_price = #{largePrice}</if>
            <if test="littlePrice != null "> and little_price = #{littlePrice}</if>
            <if test="imageUrl != null  and imageUrl != ''"> and image_url = #{imageUrl}</if>
            <if test="particulars != null  and particulars != ''"> and particulars = #{particulars}</if>
            <if test="recommend != null  and recommend != ''"> and recommend = #{recommend}</if>
            <if test="indexRecommend != null "> and index_recommend = #{indexRecommend}</if>
            <if test="likeSurvey != null "> and like_survey = #{likeSurvey}</if>
            <if test="likeBatch != null "> and like_batch = #{likeBatch}</if>
            <if test="likeNum != null "> and like_num = #{likeNum}</if>
            <if test="initialScore != null "> and initial_score = #{initialScore}</if>
            <if test="calories != null "> and calories = #{calories}</if>
            <if test="protein != null "> and protein = #{protein}</if>
            <if test="fat != null "> and fat = #{fat}</if>
            <if test="carbohydrate != null "> and carbohydrate = #{carbohydrate}</if>
            <if test="dietaryFiber != null "> and dietary_fiber = #{dietaryFiber}</if>
            <if test="cholesterol != null "> and cholesterol = #{cholesterol}</if>
            <if test="calcium != null "> and calcium = #{calcium}</if>
            <if test="sodium != null "> and sodium = #{sodium}</if>
            <if test="purine != null "> and purine = #{purine}</if>
            <if test="iron != null "> and iron = #{iron}</if>
            <if test="iodine != null "> and iodine = #{iodine}</if>
            <if test="kalium != null "> and kalium = #{kalium}</if>
            <if test="vitaminA != null "> and vitamin_a = #{vitaminA}</if>
            <if test="vitaminC != null "> and vitamin_c = #{vitaminC}</if>
            <if test="vitaminE != null "> and vitamin_e = #{vitaminE}</if>
            <if test="magnesium != null "> and magnesium = #{magnesium}</if>
            <if test="zinc != null "> and zinc = #{zinc}</if>
            <if test="glycemicIndex != null "> and glycemic_index = #{glycemicIndex}</if>
            <if test="sort != null "> and sort = #{sort}</if>
            <if test="canteenId != null "> and canteen_id = #{canteenId}</if>
            <if test="shopstallId != null "> and shopstall_id = #{shopstallId}</if>
            <if test="hideFlag != null "> and hide_flag = #{hideFlag}</if>
            <if test="convertFlag != null "> and convert_flag = #{convertFlag}</if>
            <if test="materialCost != null "> and material_cost = #{materialCost}</if>
            <if test="grossProfit != null "> and gross_profit = #{grossProfit}</if>
            <if test="grossProfitRate != null "> and gross_profit_rate = #{grossProfitRate}</if>
            <if test="publicDishes != null "> and public_dishes = #{publicDishes}</if>
            <if test="areaId != null "> and area_id = #{areaId}</if>
            <if test="revision != null "> and revision = #{revision}</if>
        </where>
    </select>

    <select id="selectMenuDishesById" parameterType="Long" resultMap="MenuDishesResult">
        <include refid="selectMenuDishesVo"/>
        where id = #{id}
    </select>

    <insert id="insertMenuDishes" parameterType="com.bonus.canteen.core.menu.domain.MenuDishes" useGeneratedKeys="true" keyProperty="id">
        insert into menu_dishes
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dishesId != null">dishes_id,</if>
            <if test="baseDishesId != null">base_dishes_id,</if>
            <if test="mealType != null">meal_type,</if>
            <if test="dishesNum != null and dishesNum != ''">dishes_num,</if>
            <if test="customId != null">custom_id,</if>
            <if test="inventoryId != null">inventory_id,</if>
            <if test="dishesName != null and dishesName != ''">dishes_name,</if>
            <if test="aliasName != null">alias_name,</if>
            <if test="pinyinInitials != null and pinyinInitials != ''">pinyin_initials,</if>
            <if test="pinyinFull != null and pinyinFull != ''">pinyin_full,</if>
            <if test="barCode != null and barCode != ''">bar_code,</if>
            <if test="intro != null and intro != ''">intro,</if>
            <if test="cookId != null">cook_id,</if>
            <if test="typeId != null">type_id,</if>
            <if test="classifyId != null">classify_id,</if>
            <if test="effectId != null">effect_id,</if>
            <if test="styleId != null">style_id,</if>
            <if test="ifLocalFeature != null">if_local_feature,</if>
            <if test="dishesDepart != null">dishes_depart,</if>
            <if test="sequence != null">sequence,</if>
            <if test="pungencyDegree != null">pungency_degree,</if>
            <if test="salesMode != null">sales_mode,</if>
            <if test="sizeType != null">size_type,</if>
            <if test="sizeJson != null">size_json,</if>
            <if test="weight != null">weight,</if>
            <if test="largeWeight != null">large_weight,</if>
            <if test="littleWeight != null">little_weight,</if>
            <if test="weightDeviation != null">weight_deviation,</if>
            <if test="price != null">price,</if>
            <if test="unitPrice != null">unit_price,</if>
            <if test="largePrice != null">large_price,</if>
            <if test="littlePrice != null">little_price,</if>
            <if test="imageUrl != null and imageUrl != ''">image_url,</if>
            <if test="particulars != null">particulars,</if>
            <if test="recommend != null and recommend != ''">recommend,</if>
            <if test="indexRecommend != null">index_recommend,</if>
            <if test="likeSurvey != null">like_survey,</if>
            <if test="likeBatch != null">like_batch,</if>
            <if test="likeNum != null">like_num,</if>
            <if test="initialScore != null">initial_score,</if>
            <if test="calories != null">calories,</if>
            <if test="protein != null">protein,</if>
            <if test="fat != null">fat,</if>
            <if test="carbohydrate != null">carbohydrate,</if>
            <if test="dietaryFiber != null">dietary_fiber,</if>
            <if test="cholesterol != null">cholesterol,</if>
            <if test="calcium != null">calcium,</if>
            <if test="sodium != null">sodium,</if>
            <if test="purine != null">purine,</if>
            <if test="iron != null">iron,</if>
            <if test="iodine != null">iodine,</if>
            <if test="kalium != null">kalium,</if>
            <if test="vitaminA != null">vitamin_a,</if>
            <if test="vitaminC != null">vitamin_c,</if>
            <if test="vitaminE != null">vitamin_e,</if>
            <if test="magnesium != null">magnesium,</if>
            <if test="zinc != null">zinc,</if>
            <if test="glycemicIndex != null">glycemic_index,</if>
            <if test="sort != null">sort,</if>
            <if test="canteenId != null">canteen_id,</if>
            <if test="shopstallId != null">shopstall_id,</if>
            <if test="hideFlag != null">hide_flag,</if>
            <if test="convertFlag != null">convert_flag,</if>
            <if test="materialCost != null">material_cost,</if>
            <if test="grossProfit != null">gross_profit,</if>
            <if test="grossProfitRate != null">gross_profit_rate,</if>
            <if test="publicDishes != null">public_dishes,</if>
            <if test="areaId != null">area_id,</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>
            <if test="remark != null">remark,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dishesId != null">#{dishesId},</if>
            <if test="baseDishesId != null">#{baseDishesId},</if>
            <if test="mealType != null">#{mealType},</if>
            <if test="dishesNum != null and dishesNum != ''">#{dishesNum},</if>
            <if test="customId != null">#{customId},</if>
            <if test="inventoryId != null">#{inventoryId},</if>
            <if test="dishesName != null and dishesName != ''">#{dishesName},</if>
            <if test="aliasName != null">#{aliasName},</if>
            <if test="pinyinInitials != null and pinyinInitials != ''">#{pinyinInitials},</if>
            <if test="pinyinFull != null and pinyinFull != ''">#{pinyinFull},</if>
            <if test="barCode != null and barCode != ''">#{barCode},</if>
            <if test="intro != null and intro != ''">#{intro},</if>
            <if test="cookId != null">#{cookId},</if>
            <if test="typeId != null">#{typeId},</if>
            <if test="classifyId != null">#{classifyId},</if>
            <if test="effectId != null">#{effectId},</if>
            <if test="styleId != null">#{styleId},</if>
            <if test="ifLocalFeature != null">#{ifLocalFeature},</if>
            <if test="dishesDepart != null">#{dishesDepart},</if>
            <if test="sequence != null">#{sequence},</if>
            <if test="pungencyDegree != null">#{pungencyDegree},</if>
            <if test="salesMode != null">#{salesMode},</if>
            <if test="sizeType != null">#{sizeType},</if>
            <if test="sizeJson != null">#{sizeJson},</if>
            <if test="weight != null">#{weight},</if>
            <if test="largeWeight != null">#{largeWeight},</if>
            <if test="littleWeight != null">#{littleWeight},</if>
            <if test="weightDeviation != null">#{weightDeviation},</if>
            <if test="price != null">#{price},</if>
            <if test="unitPrice != null">#{unitPrice},</if>
            <if test="largePrice != null">#{largePrice},</if>
            <if test="littlePrice != null">#{littlePrice},</if>
            <if test="imageUrl != null and imageUrl != ''">#{imageUrl},</if>
            <if test="particulars != null">#{particulars},</if>
            <if test="recommend != null and recommend != ''">#{recommend},</if>
            <if test="indexRecommend != null">#{indexRecommend},</if>
            <if test="likeSurvey != null">#{likeSurvey},</if>
            <if test="likeBatch != null">#{likeBatch},</if>
            <if test="likeNum != null">#{likeNum},</if>
            <if test="initialScore != null">#{initialScore},</if>
            <if test="calories != null">#{calories},</if>
            <if test="protein != null">#{protein},</if>
            <if test="fat != null">#{fat},</if>
            <if test="carbohydrate != null">#{carbohydrate},</if>
            <if test="dietaryFiber != null">#{dietaryFiber},</if>
            <if test="cholesterol != null">#{cholesterol},</if>
            <if test="calcium != null">#{calcium},</if>
            <if test="sodium != null">#{sodium},</if>
            <if test="purine != null">#{purine},</if>
            <if test="iron != null">#{iron},</if>
            <if test="iodine != null">#{iodine},</if>
            <if test="kalium != null">#{kalium},</if>
            <if test="vitaminA != null">#{vitaminA},</if>
            <if test="vitaminC != null">#{vitaminC},</if>
            <if test="vitaminE != null">#{vitaminE},</if>
            <if test="magnesium != null">#{magnesium},</if>
            <if test="zinc != null">#{zinc},</if>
            <if test="glycemicIndex != null">#{glycemicIndex},</if>
            <if test="sort != null">#{sort},</if>
            <if test="canteenId != null">#{canteenId},</if>
            <if test="shopstallId != null">#{shopstallId},</if>
            <if test="hideFlag != null">#{hideFlag},</if>
            <if test="convertFlag != null">#{convertFlag},</if>
            <if test="materialCost != null">#{materialCost},</if>
            <if test="grossProfit != null">#{grossProfit},</if>
            <if test="grossProfitRate != null">#{grossProfitRate},</if>
            <if test="publicDishes != null">#{publicDishes},</if>
            <if test="areaId != null">#{areaId},</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>
            <if test="remark != null">#{remark},</if>
         </trim>
    </insert>

    <update id="updateMenuDishes" parameterType="com.bonus.canteen.core.menu.domain.MenuDishes">
        update menu_dishes
        <trim prefix="SET" suffixOverrides=",">
            <if test="dishesId != null">dishes_id = #{dishesId},</if>
            <if test="baseDishesId != null">base_dishes_id = #{baseDishesId},</if>
            <if test="mealType != null">meal_type = #{mealType},</if>
            <if test="dishesNum != null and dishesNum != ''">dishes_num = #{dishesNum},</if>
            <if test="customId != null">custom_id = #{customId},</if>
            <if test="inventoryId != null">inventory_id = #{inventoryId},</if>
            <if test="dishesName != null and dishesName != ''">dishes_name = #{dishesName},</if>
            <if test="aliasName != null">alias_name = #{aliasName},</if>
            <if test="pinyinInitials != null and pinyinInitials != ''">pinyin_initials = #{pinyinInitials},</if>
            <if test="pinyinFull != null and pinyinFull != ''">pinyin_full = #{pinyinFull},</if>
            <if test="barCode != null and barCode != ''">bar_code = #{barCode},</if>
            <if test="intro != null and intro != ''">intro = #{intro},</if>
            <if test="cookId != null">cook_id = #{cookId},</if>
            <if test="typeId != null">type_id = #{typeId},</if>
            <if test="classifyId != null">classify_id = #{classifyId},</if>
            <if test="effectId != null">effect_id = #{effectId},</if>
            <if test="styleId != null">style_id = #{styleId},</if>
            <if test="ifLocalFeature != null">if_local_feature = #{ifLocalFeature},</if>
            <if test="dishesDepart != null">dishes_depart = #{dishesDepart},</if>
            <if test="sequence != null">sequence = #{sequence},</if>
            <if test="pungencyDegree != null">pungency_degree = #{pungencyDegree},</if>
            <if test="salesMode != null">sales_mode = #{salesMode},</if>
            <if test="sizeType != null">size_type = #{sizeType},</if>
            <if test="sizeJson != null">size_json = #{sizeJson},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="largeWeight != null">large_weight = #{largeWeight},</if>
            <if test="littleWeight != null">little_weight = #{littleWeight},</if>
            <if test="weightDeviation != null">weight_deviation = #{weightDeviation},</if>
            <if test="price != null">price = #{price},</if>
            <if test="unitPrice != null">unit_price = #{unitPrice},</if>
            <if test="largePrice != null">large_price = #{largePrice},</if>
            <if test="littlePrice != null">little_price = #{littlePrice},</if>
            <if test="imageUrl != null and imageUrl != ''">image_url = #{imageUrl},</if>
            <if test="particulars != null">particulars = #{particulars},</if>
            <if test="recommend != null and recommend != ''">recommend = #{recommend},</if>
            <if test="indexRecommend != null">index_recommend = #{indexRecommend},</if>
            <if test="likeSurvey != null">like_survey = #{likeSurvey},</if>
            <if test="likeBatch != null">like_batch = #{likeBatch},</if>
            <if test="likeNum != null">like_num = #{likeNum},</if>
            <if test="initialScore != null">initial_score = #{initialScore},</if>
            <if test="calories != null">calories = #{calories},</if>
            <if test="protein != null">protein = #{protein},</if>
            <if test="fat != null">fat = #{fat},</if>
            <if test="carbohydrate != null">carbohydrate = #{carbohydrate},</if>
            <if test="dietaryFiber != null">dietary_fiber = #{dietaryFiber},</if>
            <if test="cholesterol != null">cholesterol = #{cholesterol},</if>
            <if test="calcium != null">calcium = #{calcium},</if>
            <if test="sodium != null">sodium = #{sodium},</if>
            <if test="purine != null">purine = #{purine},</if>
            <if test="iron != null">iron = #{iron},</if>
            <if test="iodine != null">iodine = #{iodine},</if>
            <if test="kalium != null">kalium = #{kalium},</if>
            <if test="vitaminA != null">vitamin_a = #{vitaminA},</if>
            <if test="vitaminC != null">vitamin_c = #{vitaminC},</if>
            <if test="vitaminE != null">vitamin_e = #{vitaminE},</if>
            <if test="magnesium != null">magnesium = #{magnesium},</if>
            <if test="zinc != null">zinc = #{zinc},</if>
            <if test="glycemicIndex != null">glycemic_index = #{glycemicIndex},</if>
            <if test="sort != null">sort = #{sort},</if>
            <if test="canteenId != null">canteen_id = #{canteenId},</if>
            <if test="shopstallId != null">shopstall_id = #{shopstallId},</if>
            <if test="hideFlag != null">hide_flag = #{hideFlag},</if>
            <if test="convertFlag != null">convert_flag = #{convertFlag},</if>
            <if test="materialCost != null">material_cost = #{materialCost},</if>
            <if test="grossProfit != null">gross_profit = #{grossProfit},</if>
            <if test="grossProfitRate != null">gross_profit_rate = #{grossProfitRate},</if>
            <if test="publicDishes != null">public_dishes = #{publicDishes},</if>
            <if test="areaId != null">area_id = #{areaId},</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>
            <if test="remark != null">remark = #{remark},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMenuDishesById" parameterType="Long">
        delete from menu_dishes where id = #{id}
    </delete>

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

    <select id="getDishesType" resultType="com.bonus.canteen.core.menu.domain.MapBean" parameterType="com.bonus.canteen.core.menu.domain.MapBean">
        select dict_label as `key`,dict_value as `value` from sys_dict_data where is_default ='Y' and dict_type = #{key} order by  dict_sort
    </select>


    <select id="getOne" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO" resultMap="MenuDishesResult">
        select * from menu_dishes where  area_id = #{areaId}  and (
        dishes_num =#{dishesNum} or
        dishes_name = #{dishesName}
        ) limit 1
    </select>

    <insert id="addMenuDishesBase"  parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO">
        insert into menu_dishes_base
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="baseDishesId != null">base_dishes_id,</if>
            <if test="dishesName != null">dishes_name,</if>
            <if test="crby != null">crby,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test=" baseDishesId!= null">#{baseDishesId},</if>
            <if test=" dishesName!= null">#{dishesName},</if>
            <if test="crby != null">#{crby},</if>
        </trim>
    </insert>

    <insert id="addMenuDishes"  parameterType="com.bonus.canteen.core.menu.dto.MenuDishesDTO">
        insert into menu_dishes
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="dishesId != null">dishes_id,</if>
            <if test="baseDishesId != null">base_dishes_id,</if>
            <if test="sizeType != null">size_type,</if>
            <if test="materialCost != null">material_cost,</if>
            <if test="publicDishes != null">public_dishes,</if>
            <if test="areaId != null">area_id,</if>
            <if test="canteenId != null">canteen_id,</if>
            <if test="shopstallId != null">shopstall_id,</if>
            <if test="dishesNum != null">dishes_num,</if>
            <if test="dishesName != null">dishes_name,</if>
            <if test="price != null">price,</if>
            <if test="weight != null">weight,</if>
            <if test="weightDeviation != null">weight_deviation,</if>
            <if test="imageUrl != null">image_url,</if>
            <if test="effectId != null">effect_id,</if>
            <if test="styleId != null">style_id,</if>
            <if test="cookId != null">cook_id,</if>
            <if test="classifyId != null">classify_id,</if>
            <if test="crby != null">create_by,</if>
            <if test="customId != null">custom_id,</if>

        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="dishesId != null">#{dishesId},</if>
            <if test="baseDishesId != null">#{baseDishesId},</if>
            <if test="sizeType != null">#{sizeType},</if>
            <if test="materialCost != null">#{materialCost},</if>
            <if test="publicDishes != null">#{publicDishes},</if>
            <if test="areaId != null">#{areaId},</if>
            <if test="canteenId != null">#{canteenId},</if>
            <if test="shopstallId != null">#{shopstallId},</if>
            <if test="dishesNum != null">#{dishesNum},</if>
            <if test="dishesName != null">#{dishesName},</if>
            <if test="price != null">#{price},</if>
            <if test="weight != null">#{weight},</if>
            <if test="weightDeviation != null">#{weightDeviation},</if>
            <if test="imageUrl != null">#{imageUrl},</if>
            <if test="effectId != null">#{effectId}},</if>
            <if test="styleId != null">#{styleId},</if>
            <if test="cookId != null">#{cookId},</if>
            <if test="classifyId != null">#{classifyId},</if>
            <if test="crby != null">#{crby},</if>
            <if test="customId != null">#{customId},</if>
        </trim>
    </insert>


    <insert id="adddishesLabel" parameterType="com.bonus.canteen.core.menu.domain.MenuDishesRelation">
        insert into menu_dishes_label_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">label_id,</if>
            <if test="dishesId != null">dishes_id,</if>
            <if test="crby != null">crby,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">#{keyWordId},</if>
            <if test="dishesId != null">#{dishesId},</if>
            <if test="crby != null">#{crby},</if>
        </trim>
    </insert>


    <insert id="adddishesTaste"  parameterType="com.bonus.canteen.core.menu.domain.MenuDishesRelation">
        insert into menu_dishes_taste_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">taste_id,</if>
            <if test="dishesId != null">dishes_id,</if>
            <if test="crby != null">crby,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">#{keyWordId},</if>
            <if test="dishesId != null">#{dishesId},</if>
            <if test="crby != null">#{crby},</if>
        </trim>
    </insert>

    <insert id="adddishesSeason"  parameterType="com.bonus.canteen.core.menu.domain.MenuDishesRelation">
        insert into menu_dishes_season_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">season_id,</if>
            <if test="dishesId != null">dishes_id,</if>
            <if test="crby != null">crby,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">#{keyWordId},</if>
            <if test="dishesId != null">#{dishesId},</if>
            <if test="crby != null">#{crby},</if>
        </trim>
    </insert>

    <insert id="adddishesSuit" parameterType="com.bonus.canteen.core.menu.domain.MenuDishesRelation">
        insert into menu_dishes_suit_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">suit_id,</if>
            <if test="dishesId != null">dishes_id,</if>
            <if test="crby != null">crby,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">#{keyWordId},</if>
            <if test="dishesId != null">#{dishesId},</if>
            <if test="crby != null">#{crby},</if>
        </trim>
    </insert>

    <insert id="adddishesMeal" parameterType="com.bonus.canteen.core.menu.domain.MenuDishesRelation">
        insert into menu_dishes_meal_relation
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">meal_id,</if>
            <if test="dishesId != null">dishes_id,</if>
            <if test="crby != null">crby,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="keyWordId != null">#{keyWordId},</if>
            <if test="dishesId != null">#{dishesId},</if>
            <if test="crby != null">#{crby},</if>
        </trim>
    </insert>

    <select id="getNutritionEntity" resultType="com.bonus.canteen.core.utils.NutritionEntity" parameterType="com.bonus.canteen.core.menu.dto.MenuDishesAddMaterialDTO">
        select calories,fat,protein,carbohydrate,dietary_fiber as dietaryFiber,
        cholesterol,calcium,sodium,purine,iron,
        iodine,kalium,vitamin_a as vitaminA,vitamin_c as vitaminC,vitamin_e as vitaminE,
        magnesium,zinc,glycemic_index as glycemicIndex
        from menu_nutrition where nutrition_id = #{materialId}
    </select>

    <select id="addFinalNutrition" resultType="int"></select>
</mapper>
