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

import org.apache.commons.lang3.StringUtils;

public enum OrderStateEnum {
   PLACE(1, "已下单"),
   FINISH(2, "已完成"),
   CANCEL(3, "已取消"),
   WAIT_PLACE(4, "待下单");

   private final Integer key;
   private final String desc;

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

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

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

   public static String getDescByKey(Integer key) {
      for (OrderStateEnum orderState : OrderStateEnum.values()) {
         if (orderState.getKey().equals(key)) {
            return orderState.getDesc();
         }
      }
      return StringUtils.EMPTY;
   }
}
