<?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.CookNutritionMapper">
    <resultMap type="com.bonus.canteen.core.cook.domain.CookNutrition" id="CookNutritionResult">
        <result property="nutritionId"    column="nutrition_id"    />
        <result property="nutritionName"    column="nutrition_name"    />
        <result property="nutritionCode"    column="nutrition_code"    />
        <result property="imgUrl"    column="img_url"    />
        <result property="weight"    column="weight"    />
        <result property="price"    column="price"    />
        <result property="color"    column="color"    />
        <result property="label"    column="label"    />
        <result property="processingMethod"    column="processing_method"    />
        <result property="processingTime"    column="processing_time"    />
        <result property="recommendedCombination"    column="recommended_combination"    />
        <result property="combinationNotRecommended"    column="combination_not_recommended"    />
        <result property="edible"    column="edible"    />
        <result property="water"    column="water"    />
        <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="ash"    column="ash"    />
        <result property="vitaminA"    column="vitamin_a"    />
        <result property="carotene"    column="carotene"    />
        <result property="thiamine"    column="thiamine"    />
        <result property="riboflavin"    column="riboflavin"    />
        <result property="niacin"    column="niacin"    />
        <result property="vitaminC"    column="vitamin_c"    />
        <result property="vitaminD"    column="vitamin_d"    />
        <result property="vitaminE"    column="vitamin_e"    />
        <result property="choline"    column="choline"    />
        <result property="biotin"    column="biotin"    />
        <result property="pantothenicAcid"    column="pantothenic_acid"    />
        <result property="guanine"    column="guanine"    />
        <result property="adenine"    column="adenine"    />
        <result property="hypoxanthine"    column="hypoxanthine"    />
        <result property="xanthine"    column="xanthine"    />
        <result property="purine"    column="purine"    />
        <result property="glycemicIndex"    column="glycemic_index"    />
        <result property="totalPhytosterolContent"    column="total_phytosterol_content"    />
        <result property="cerealSterol"    column="cereal_sterol"    />
        <result property="cameliaSterol"    column="camelia_sterol"    />
        <result property="sterol"    column="sterol"    />
        <result property="cerealSteranol"    column="cereal_steranol"    />
        <result property="rapesanol"    column="rapesanol"    />
        <result property="rapeseedSteranol"    column="rapeseed_steranol"    />
        <result property="luteinZeaxanthin"    column="lutein_zeaxanthin"    />
        <result property="quercetin"    column="quercetin"    />
        <result property="myricetin"    column="myricetin"    />
        <result property="luteolin"    column="luteolin"    />
        <result property="kaemPferol"    column="kaem_pferol"    />
        <result property="apigenin"    column="apigenin"    />
        <result property="isoflavone"    column="isoflavone"    />
        <result property="daidzein"    column="daidzein"    />
        <result property="genistein"    column="genistein"    />
        <result property="glycitein"    column="glycitein"    />
        <result property="anthocyan"    column="anthocyan"    />
        <result property="resveratrol"    column="resveratrol"    />
        <result property="polydatin"    column="polydatin"    />
        <result property="originPlace"    column="origin_place"    />
        <result property="calcium"    column="calcium"    />
        <result property="phosphorus"    column="phosphorus"    />
        <result property="kalium"    column="kalium"    />
        <result property="sodium"    column="sodium"    />
        <result property="magnesium"    column="magnesium"    />
        <result property="iron"    column="iron"    />
        <result property="zinc"    column="zinc"    />
        <result property="selenium"    column="selenium"    />
        <result property="cuprum"    column="cuprum"    />
        <result property="manganese"    column="manganese"    />
        <result property="isoleucine"    column="isoleucine"    />
        <result property="leucine"    column="leucine"    />
        <result property="lysine"    column="lysine"    />
        <result property="saaTotal"    column="saa_total"    />
        <result property="aaaTotal"    column="aaa_total"    />
        <result property="threonine"    column="threonine"    />
        <result property="tryptophan"    column="tryptophan"    />
        <result property="valine"    column="valine"    />
        <result property="arginine"    column="arginine"    />
        <result property="histidine"    column="histidine"    />
        <result property="alanine"    column="alanine"    />
        <result property="asparticAcid"    column="aspartic_acid"    />
        <result property="glutamate"    column="glutamate"    />
        <result property="glycine"    column="glycine"    />
        <result property="proline"    column="proline"    />
        <result property="serine"    column="serine"    />
        <result property="fattyAcid"    column="fatty_acid"    />
        <result property="saturatedFattyAcid"    column="saturated_fatty_acid"    />
        <result property="monounsaturatedFattyAcid"    column="monounsaturated_fatty_acid"    />
        <result property="polyunsaturatedFattyAcid"    column="polyunsaturated_fatty_acid"    />
        <result property="iodine"    column="iodine"    />
        <result property="folic"    column="folic"    />
        <result property="retinol"    column="retinol"    />
        <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="smallTypeName"    column="small_type_name"    />
        <result property="smallTypeId"    column="small_type_id"    />
        <result property="bigTypeName"    column="big_type_name"    />
        <result property="bigTypeId"    column="big_type_id"    />
    </resultMap>

    <sql id="selectCookNutritionVo">
        select cn.nutrition_id, nutrition_name, nutrition_code,  img_url, weight, price, color, label,
               processing_method, processing_time, recommended_combination, combination_not_recommended, edible, water,
               calories, protein, fat, carbohydrate, dietary_fiber, cholesterol, ash, vitamin_a, carotene, thiamine,
               riboflavin, niacin, vitamin_c, vitamin_d, vitamin_e, choline, biotin, pantothenic_acid, guanine, adenine,
               hypoxanthine, xanthine, purine, glycemic_index, total_phytosterol_content, cereal_sterol, camelia_sterol,
               sterol, cereal_steranol, rapesanol, rapeseed_steranol, lutein_zeaxanthin, quercetin, myricetin, luteolin,
               kaem_pferol, apigenin, isoflavone, daidzein, genistein, glycitein, anthocyan, resveratrol, polydatin,
               origin_place, calcium, phosphorus, kalium, sodium, magnesium, iron, zinc, selenium, cuprum, manganese,
               isoleucine, leucine, lysine, saa_total, aaa_total, threonine, tryptophan, valine, arginine, histidine,
               alanine, aspartic_acid, glutamate, glycine, proline, serine, fatty_acid, saturated_fatty_acid,
               monounsaturated_fatty_acid, polyunsaturated_fatty_acid, iodine, folic, retinol, cn.create_by, cn.create_time,
               cn.update_by, cn.update_time,
               cnt.nutrition_type_id as small_type_id, cnt.nutrition_type_name as small_type_name,
               cnt1.nutrition_type_id as big_type_id, cnt1.nutrition_type_name as big_type_name
        from cook_nutrition cn
        left join cook_nutrition_type cnt on cn.nutrition_type_id = cnt.nutrition_type_id
        left join cook_nutrition_type cnt1 on cnt1.nutrition_type_id = cnt.parent_id
    </sql>

    <select id="selectCookNutritionList" parameterType="com.bonus.canteen.core.cook.domain.CookNutrition" resultMap="CookNutritionResult">
        <include refid="selectCookNutritionVo"/>
        <where>
            <if test="nutritionName != null  and nutritionName != ''">and nutrition_name like concat('%',
                #{nutritionName}, '%')
            </if>
            <if test="nutritionTypeIds != null and nutritionTypeIds.size() > 0">
                and cn.nutrition_type_id in
                <foreach item="item" index="index" collection="nutritionTypeIds" open="(" separator="," close=")">
                    #{item}
                </foreach>
            </if>
        </where>
        order by cn.create_time desc
    </select>
    
    <select id="selectCookNutritionByNutritionId" parameterType="Long" resultMap="CookNutritionResult">
        <include refid="selectCookNutritionVo"/>
        where nutrition_id = #{nutritionId}
    </select>
    <select id="checkIsExist" resultType="java.lang.Integer">
        select count(1) from cook_material where nutrition_id = #{nutritionId}
    </select>
    <select id="getListByCategoryId" resultType="com.bonus.canteen.core.cook.domain.CookNutrition">
        <include refid="selectCookNutritionVo"/>
        <where>
            <if test="categoryId != null  and categoryId != ''"> and cn.nutrition_type_id = #{categoryId}</if>
        </where>
    </select>
    <select id="checkIsExistByName" resultType="java.lang.Integer">
        select count(1) from cook_nutrition where nutrition_name = #{nutritionName}
        <if test="nutritionId != null"> and nutrition_id != #{nutritionId}</if>
    </select>
    <select id="getNutritionEntity" resultType="com.bonus.canteen.core.utils.NutritionEntity">
        <include refid="selectCookNutritionVo"/>
        where nutrition_id =  (select nutrition_id from cook_material where material_id = #{materialId})
    </select>


    <insert id="insertCookNutrition" parameterType="com.bonus.canteen.core.cook.domain.CookNutrition" useGeneratedKeys="true" keyProperty="nutritionId">
        insert into cook_nutrition
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="nutritionName != null and nutritionName != ''">nutrition_name,</if>
            <if test="nutritionCode != null and nutritionCode != ''">nutrition_code,</if>
            <if test="nutritionTypeId != null">nutrition_type_id,</if>
            <if test="imgUrl != null and imgUrl != ''">img_url,</if>
            <if test="weight != null">weight,</if>
            <if test="price != null">price,</if>
            <if test="color != null and color != ''">color,</if>
            <if test="label != null and label != ''">label,</if>
            <if test="processingMethod != null and processingMethod != ''">processing_method,</if>
            <if test="processingTime != null">processing_time,</if>
            <if test="recommendedCombination != null and recommendedCombination != ''">recommended_combination,</if>
            <if test="combinationNotRecommended != null and combinationNotRecommended != ''">combination_not_recommended,</if>
            <if test="edible != null">edible,</if>
            <if test="water != null">water,</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="ash != null">ash,</if>
            <if test="vitaminA != null">vitamin_a,</if>
            <if test="carotene != null">carotene,</if>
            <if test="thiamine != null">thiamine,</if>
            <if test="riboflavin != null">riboflavin,</if>
            <if test="niacin != null">niacin,</if>
            <if test="vitaminC != null">vitamin_c,</if>
            <if test="vitaminD != null">vitamin_d,</if>
            <if test="vitaminE != null">vitamin_e,</if>
            <if test="choline != null">choline,</if>
            <if test="biotin != null">biotin,</if>
            <if test="pantothenicAcid != null">pantothenic_acid,</if>
            <if test="guanine != null">guanine,</if>
            <if test="adenine != null">adenine,</if>
            <if test="hypoxanthine != null">hypoxanthine,</if>
            <if test="xanthine != null">xanthine,</if>
            <if test="purine != null">purine,</if>
            <if test="glycemicIndex != null">glycemic_index,</if>
            <if test="totalPhytosterolContent != null">total_phytosterol_content,</if>
            <if test="cerealSterol != null">cereal_sterol,</if>
            <if test="cameliaSterol != null">camelia_sterol,</if>
            <if test="sterol != null">sterol,</if>
            <if test="cerealSteranol != null">cereal_steranol,</if>
            <if test="rapesanol != null">rapesanol,</if>
            <if test="rapeseedSteranol != null">rapeseed_steranol,</if>
            <if test="luteinZeaxanthin != null">lutein_zeaxanthin,</if>
            <if test="quercetin != null">quercetin,</if>
            <if test="myricetin != null">myricetin,</if>
            <if test="luteolin != null">luteolin,</if>
            <if test="kaemPferol != null">kaem_pferol,</if>
            <if test="apigenin != null">apigenin,</if>
            <if test="isoflavone != null">isoflavone,</if>
            <if test="daidzein != null">daidzein,</if>
            <if test="genistein != null">genistein,</if>
            <if test="glycitein != null">glycitein,</if>
            <if test="anthocyan != null">anthocyan,</if>
            <if test="resveratrol != null">resveratrol,</if>
            <if test="polydatin != null">polydatin,</if>
            <if test="originPlace != null and originPlace != ''">origin_place,</if>
            <if test="calcium != null">calcium,</if>
            <if test="phosphorus != null">phosphorus,</if>
            <if test="kalium != null">kalium,</if>
            <if test="sodium != null">sodium,</if>
            <if test="magnesium != null">magnesium,</if>
            <if test="iron != null">iron,</if>
            <if test="zinc != null">zinc,</if>
            <if test="selenium != null">selenium,</if>
            <if test="cuprum != null">cuprum,</if>
            <if test="manganese != null">manganese,</if>
            <if test="isoleucine != null">isoleucine,</if>
            <if test="leucine != null">leucine,</if>
            <if test="lysine != null">lysine,</if>
            <if test="saaTotal != null">saa_total,</if>
            <if test="aaaTotal != null">aaa_total,</if>
            <if test="threonine != null">threonine,</if>
            <if test="tryptophan != null">tryptophan,</if>
            <if test="valine != null">valine,</if>
            <if test="arginine != null">arginine,</if>
            <if test="histidine != null">histidine,</if>
            <if test="alanine != null">alanine,</if>
            <if test="asparticAcid != null">aspartic_acid,</if>
            <if test="glutamate != null">glutamate,</if>
            <if test="glycine != null">glycine,</if>
            <if test="proline != null">proline,</if>
            <if test="serine != null">serine,</if>
            <if test="fattyAcid != null">fatty_acid,</if>
            <if test="saturatedFattyAcid != null">saturated_fatty_acid,</if>
            <if test="monounsaturatedFattyAcid != null">monounsaturated_fatty_acid,</if>
            <if test="polyunsaturatedFattyAcid != null">polyunsaturated_fatty_acid,</if>
            <if test="iodine != null">iodine,</if>
            <if test="folic != null">folic,</if>
            <if test="retinol != null">retinol,</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="nutritionName != null and nutritionName != ''">#{nutritionName},</if>
            <if test="nutritionCode != null and nutritionCode != ''">#{nutritionCode},</if>
            <if test="nutritionTypeId != null">#{nutritionTypeId},</if>
            <if test="imgUrl != null and imgUrl != ''">#{imgUrl},</if>
            <if test="weight != null">#{weight},</if>
            <if test="price != null">#{price},</if>
            <if test="color != null and color != ''">#{color},</if>
            <if test="label != null and label != ''">#{label},</if>
            <if test="processingMethod != null and processingMethod != ''">#{processingMethod},</if>
            <if test="processingTime != null">#{processingTime},</if>
            <if test="recommendedCombination != null and recommendedCombination != ''">#{recommendedCombination},</if>
            <if test="combinationNotRecommended != null and combinationNotRecommended != ''">#{combinationNotRecommended},</if>
            <if test="edible != null">#{edible},</if>
            <if test="water != null">#{water},</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="ash != null">#{ash},</if>
            <if test="vitaminA != null">#{vitaminA},</if>
            <if test="carotene != null">#{carotene},</if>
            <if test="thiamine != null">#{thiamine},</if>
            <if test="riboflavin != null">#{riboflavin},</if>
            <if test="niacin != null">#{niacin},</if>
            <if test="vitaminC != null">#{vitaminC},</if>
            <if test="vitaminD != null">#{vitaminD},</if>
            <if test="vitaminE != null">#{vitaminE},</if>
            <if test="choline != null">#{choline},</if>
            <if test="biotin != null">#{biotin},</if>
            <if test="pantothenicAcid != null">#{pantothenicAcid},</if>
            <if test="guanine != null">#{guanine},</if>
            <if test="adenine != null">#{adenine},</if>
            <if test="hypoxanthine != null">#{hypoxanthine},</if>
            <if test="xanthine != null">#{xanthine},</if>
            <if test="purine != null">#{purine},</if>
            <if test="glycemicIndex != null">#{glycemicIndex},</if>
            <if test="totalPhytosterolContent != null">#{totalPhytosterolContent},</if>
            <if test="cerealSterol != null">#{cerealSterol},</if>
            <if test="cameliaSterol != null">#{cameliaSterol},</if>
            <if test="sterol != null">#{sterol},</if>
            <if test="cerealSteranol != null">#{cerealSteranol},</if>
            <if test="rapesanol != null">#{rapesanol},</if>
            <if test="rapeseedSteranol != null">#{rapeseedSteranol},</if>
            <if test="luteinZeaxanthin != null">#{luteinZeaxanthin},</if>
            <if test="quercetin != null">#{quercetin},</if>
            <if test="myricetin != null">#{myricetin},</if>
            <if test="luteolin != null">#{luteolin},</if>
            <if test="kaemPferol != null">#{kaemPferol},</if>
            <if test="apigenin != null">#{apigenin},</if>
            <if test="isoflavone != null">#{isoflavone},</if>
            <if test="daidzein != null">#{daidzein},</if>
            <if test="genistein != null">#{genistein},</if>
            <if test="glycitein != null">#{glycitein},</if>
            <if test="anthocyan != null">#{anthocyan},</if>
            <if test="resveratrol != null">#{resveratrol},</if>
            <if test="polydatin != null">#{polydatin},</if>
            <if test="originPlace != null and originPlace != ''">#{originPlace},</if>
            <if test="calcium != null">#{calcium},</if>
            <if test="phosphorus != null">#{phosphorus},</if>
            <if test="kalium != null">#{kalium},</if>
            <if test="sodium != null">#{sodium},</if>
            <if test="magnesium != null">#{magnesium},</if>
            <if test="iron != null">#{iron},</if>
            <if test="zinc != null">#{zinc},</if>
            <if test="selenium != null">#{selenium},</if>
            <if test="cuprum != null">#{cuprum},</if>
            <if test="manganese != null">#{manganese},</if>
            <if test="isoleucine != null">#{isoleucine},</if>
            <if test="leucine != null">#{leucine},</if>
            <if test="lysine != null">#{lysine},</if>
            <if test="saaTotal != null">#{saaTotal},</if>
            <if test="aaaTotal != null">#{aaaTotal},</if>
            <if test="threonine != null">#{threonine},</if>
            <if test="tryptophan != null">#{tryptophan},</if>
            <if test="valine != null">#{valine},</if>
            <if test="arginine != null">#{arginine},</if>
            <if test="histidine != null">#{histidine},</if>
            <if test="alanine != null">#{alanine},</if>
            <if test="asparticAcid != null">#{asparticAcid},</if>
            <if test="glutamate != null">#{glutamate},</if>
            <if test="glycine != null">#{glycine},</if>
            <if test="proline != null">#{proline},</if>
            <if test="serine != null">#{serine},</if>
            <if test="fattyAcid != null">#{fattyAcid},</if>
            <if test="saturatedFattyAcid != null">#{saturatedFattyAcid},</if>
            <if test="monounsaturatedFattyAcid != null">#{monounsaturatedFattyAcid},</if>
            <if test="polyunsaturatedFattyAcid != null">#{polyunsaturatedFattyAcid},</if>
            <if test="iodine != null">#{iodine},</if>
            <if test="folic != null">#{folic},</if>
            <if test="retinol != null">#{retinol},</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="updateCookNutrition" parameterType="com.bonus.canteen.core.cook.domain.CookNutrition">
        update cook_nutrition
        <trim prefix="SET" suffixOverrides=",">
            <if test="nutritionName != null and nutritionName != ''">nutrition_name = #{nutritionName},</if>
            <if test="nutritionCode != null and nutritionCode != ''">nutrition_code = #{nutritionCode},</if>
            <if test="nutritionTypeId != null">nutrition_type_id = #{nutritionTypeId},</if>
            <if test="imgUrl != null and imgUrl != ''">img_url = #{imgUrl},</if>
            <if test="weight != null">weight = #{weight},</if>
            <if test="price != null">price = #{price},</if>
            <if test="color != null and color != ''">color = #{color},</if>
            <if test="label != null and label != ''">label = #{label},</if>
            <if test="processingMethod != null and processingMethod != ''">processing_method = #{processingMethod},</if>
            <if test="processingTime != null">processing_time = #{processingTime},</if>
            <if test="recommendedCombination != null and recommendedCombination != ''">recommended_combination = #{recommendedCombination},</if>
            <if test="combinationNotRecommended != null and combinationNotRecommended != ''">combination_not_recommended = #{combinationNotRecommended},</if>
            <if test="edible != null">edible = #{edible},</if>
            <if test="water != null">water = #{water},</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="ash != null">ash = #{ash},</if>
            <if test="vitaminA != null">vitamin_a = #{vitaminA},</if>
            <if test="carotene != null">carotene = #{carotene},</if>
            <if test="thiamine != null">thiamine = #{thiamine},</if>
            <if test="riboflavin != null">riboflavin = #{riboflavin},</if>
            <if test="niacin != null">niacin = #{niacin},</if>
            <if test="vitaminC != null">vitamin_c = #{vitaminC},</if>
            <if test="vitaminD != null">vitamin_d = #{vitaminD},</if>
            <if test="vitaminE != null">vitamin_e = #{vitaminE},</if>
            <if test="choline != null">choline = #{choline},</if>
            <if test="biotin != null">biotin = #{biotin},</if>
            <if test="pantothenicAcid != null">pantothenic_acid = #{pantothenicAcid},</if>
            <if test="guanine != null">guanine = #{guanine},</if>
            <if test="adenine != null">adenine = #{adenine},</if>
            <if test="hypoxanthine != null">hypoxanthine = #{hypoxanthine},</if>
            <if test="xanthine != null">xanthine = #{xanthine},</if>
            <if test="purine != null">purine = #{purine},</if>
            <if test="glycemicIndex != null">glycemic_index = #{glycemicIndex},</if>
            <if test="totalPhytosterolContent != null">total_phytosterol_content = #{totalPhytosterolContent},</if>
            <if test="cerealSterol != null">cereal_sterol = #{cerealSterol},</if>
            <if test="cameliaSterol != null">camelia_sterol = #{cameliaSterol},</if>
            <if test="sterol != null">sterol = #{sterol},</if>
            <if test="cerealSteranol != null">cereal_steranol = #{cerealSteranol},</if>
            <if test="rapesanol != null">rapesanol = #{rapesanol},</if>
            <if test="rapeseedSteranol != null">rapeseed_steranol = #{rapeseedSteranol},</if>
            <if test="luteinZeaxanthin != null">lutein_zeaxanthin = #{luteinZeaxanthin},</if>
            <if test="quercetin != null">quercetin = #{quercetin},</if>
            <if test="myricetin != null">myricetin = #{myricetin},</if>
            <if test="luteolin != null">luteolin = #{luteolin},</if>
            <if test="kaemPferol != null">kaem_pferol = #{kaemPferol},</if>
            <if test="apigenin != null">apigenin = #{apigenin},</if>
            <if test="isoflavone != null">isoflavone = #{isoflavone},</if>
            <if test="daidzein != null">daidzein = #{daidzein},</if>
            <if test="genistein != null">genistein = #{genistein},</if>
            <if test="glycitein != null">glycitein = #{glycitein},</if>
            <if test="anthocyan != null">anthocyan = #{anthocyan},</if>
            <if test="resveratrol != null">resveratrol = #{resveratrol},</if>
            <if test="polydatin != null">polydatin = #{polydatin},</if>
            <if test="originPlace != null and originPlace != ''">origin_place = #{originPlace},</if>
            <if test="calcium != null">calcium = #{calcium},</if>
            <if test="phosphorus != null">phosphorus = #{phosphorus},</if>
            <if test="kalium != null">kalium = #{kalium},</if>
            <if test="sodium != null">sodium = #{sodium},</if>
            <if test="magnesium != null">magnesium = #{magnesium},</if>
            <if test="iron != null">iron = #{iron},</if>
            <if test="zinc != null">zinc = #{zinc},</if>
            <if test="selenium != null">selenium = #{selenium},</if>
            <if test="cuprum != null">cuprum = #{cuprum},</if>
            <if test="manganese != null">manganese = #{manganese},</if>
            <if test="isoleucine != null">isoleucine = #{isoleucine},</if>
            <if test="leucine != null">leucine = #{leucine},</if>
            <if test="lysine != null">lysine = #{lysine},</if>
            <if test="saaTotal != null">saa_total = #{saaTotal},</if>
            <if test="aaaTotal != null">aaa_total = #{aaaTotal},</if>
            <if test="threonine != null">threonine = #{threonine},</if>
            <if test="tryptophan != null">tryptophan = #{tryptophan},</if>
            <if test="valine != null">valine = #{valine},</if>
            <if test="arginine != null">arginine = #{arginine},</if>
            <if test="histidine != null">histidine = #{histidine},</if>
            <if test="alanine != null">alanine = #{alanine},</if>
            <if test="asparticAcid != null">aspartic_acid = #{asparticAcid},</if>
            <if test="glutamate != null">glutamate = #{glutamate},</if>
            <if test="glycine != null">glycine = #{glycine},</if>
            <if test="proline != null">proline = #{proline},</if>
            <if test="serine != null">serine = #{serine},</if>
            <if test="fattyAcid != null">fatty_acid = #{fattyAcid},</if>
            <if test="saturatedFattyAcid != null">saturated_fatty_acid = #{saturatedFattyAcid},</if>
            <if test="monounsaturatedFattyAcid != null">monounsaturated_fatty_acid = #{monounsaturatedFattyAcid},</if>
            <if test="polyunsaturatedFattyAcid != null">polyunsaturated_fatty_acid = #{polyunsaturatedFattyAcid},</if>
            <if test="iodine != null">iodine = #{iodine},</if>
            <if test="folic != null">folic = #{folic},</if>
            <if test="retinol != null">retinol = #{retinol},</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 nutrition_id = #{nutritionId}
    </update>

    <delete id="deleteCookNutritionByNutritionId" parameterType="Long">
        delete from cook_nutrition where nutrition_id = #{nutritionId}
    </delete>

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

    <select id="checkIsExistByCode" resultType="int">
        select count(1) from cook_nutrition where nutrition_code = #{nutritionCode}
        <if test="nutritionId != null"> and nutrition_id != #{nutritionId}</if>
    </select>
</mapper>