package com.bonus.canteen.core.account.constants;

import java.util.*;
import java.util.stream.Collectors;

public enum AccStatusEnum {
   NORMAL(0, "正常"),
   DEACTIVATE(1, "停用");

   private final Integer key;
   private final String desc;

   private static final Map<Integer, AccStatusEnum> ENUM_MAP = Arrays.stream(values())
           .collect(Collectors.toMap(AccStatusEnum::getKey, e -> e));

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

   public static String getDesc(Integer key) {
      AccStatusEnum enumValue = ENUM_MAP.get(key);
      return enumValue != null ? enumValue.getDesc() : "";
   }

   public static List<Integer> getAllKeys() {
      return Arrays.stream(AccStatusEnum.values())
              .map(AccStatusEnum::getKey)
              .collect(Collectors.toList());
   }
   public static AccStatusEnum getEnum(Integer key) {
      return ENUM_MAP.get(key);
   }

   public Integer getKey() {
      return this.key;
   }

   public String getDesc() {
      return this.desc;
   }
}
