package com.bonus.canteen.core.android.vo;

import cn.hutool.core.collection.ListUtil;
import lombok.Data;
import lombok.Getter;

import java.util.List;

/**
 * @author 19814
 */
@Getter
public enum CookMealtimeTypeEnum {
   // 餐次类型
   MEALTIME_BREAKFAST(1, "早餐"),
   MEALTIME_LUNCH(2, "午餐"),
   MEALTIME_AFTERNOON_TEA(3, "下午茶"),
   MEALTIME_DINNER(4, "晚餐"),
   MEALTIME_MIDNIGHT_SNACK(5, "夜宵");

    /**
     * 早餐
     */
   private final Integer key;
   /**
    * 描述
    */
   private final String desc;

   private CookMealtimeTypeEnum(Integer key, String desc) {
      this.key = key;
      this.desc = desc;
   }

   public static CookMealtimeTypeEnum getTypeEnum(Integer key) {
      CookMealtimeTypeEnum[] var1 = values();
       for (CookMealtimeTypeEnum typeEnum : var1) {
           if (typeEnum.getKey().equals(key)) {
               return typeEnum;
           }
       }

      return null;
   }

   public static String getDescByKey(Integer key) {
      CookMealtimeTypeEnum[] enums = values();

       for (CookMealtimeTypeEnum anEnum : enums) {
           if (anEnum.getKey().equals(key)) {
               return anEnum.getDesc();
           }
       }

      return "";
   }

   public static Integer getKeyByDesc(String desc) {
      CookMealtimeTypeEnum[] enums = values();

       for (CookMealtimeTypeEnum anEnum : enums) {
           if (anEnum.getDesc().equals(desc)) {
               return anEnum.getKey();
           }
       }

      return null;
   }

   public static List<Integer> allTypeList() {
      return ListUtil.toList(new Integer[]{MEALTIME_BREAKFAST.getKey(), MEALTIME_LUNCH.getKey(), MEALTIME_AFTERNOON_TEA.getKey(), MEALTIME_DINNER.getKey(), MEALTIME_MIDNIGHT_SNACK.getKey()});
   }

}
