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

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

public enum WalletBalanceOperationEnum {
   ADD_BAL(1, "钱包加钱"),
   REDUCE_BAL(2, "钱包减钱"),
   FROZEN_BAL(3, "钱包冻结"),
   UNFROZEN_BAL(4, "钱包解冻");

   private final Integer key;
   private final String desc;

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

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

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

   public static WalletBalanceOperationEnum getEnum(Integer key) {
      return ENUM_MAP.get(key);
   }

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

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