package cn.iocoder.yudao.module.system.enums.Nutrition;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.math.BigDecimal;
import java.math.RoundingMode;

/**
 * @Author:qjq
 * @Date:2024/4/22 下午3:56
 */
@Getter
@AllArgsConstructor
public enum NutritionEnum {
    //能量每日推荐
    NL(BigDecimal.valueOf(8400),"能量"),
    //蛋白质每日推荐
     DBZ(BigDecimal.valueOf(60),"蛋白质"),
    //脂肪每日推荐
    ZF(BigDecimal.valueOf(60),"脂肪"),
    //碳水化合物每日推荐
    TSHHW(BigDecimal.valueOf(300),"碳水化合物");
    private static final BigDecimal ONE=BigDecimal.valueOf(100);
    private final BigDecimal num;
    private final String name;
    public static String percentage(String naem,BigDecimal big){
        if(NutritionEnum.NL.getName().equals(naem)){
           return big.divide(NutritionEnum.NL.getNum(),4, RoundingMode.UP).multiply(ONE).setScale(2,RoundingMode.UP)+"%";
        }else if(NutritionEnum.DBZ.getName().equals(naem)){
            return big.divide(NutritionEnum.DBZ.getNum(),4, RoundingMode.UP).multiply(ONE).setScale(2,RoundingMode.UP)+"%";
        }else if (NutritionEnum.ZF.getName().equals(naem)){
            return big.divide(NutritionEnum.ZF.getNum(),4, RoundingMode.UP).multiply(ONE).setScale(2,RoundingMode.UP)+"%";
        }else{
            return big.divide(NutritionEnum.TSHHW.getNum(),4, RoundingMode.UP).multiply(ONE).setScale(2,RoundingMode.UP)+"%";
        }
    }
}
