package com.red.circle.common.business.enums;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author pengliang on 2020/1/11 10:27
 */
public enum ConsoleAccountStatusEnum {

  /**
   * 正常.
   */
  NORMAL("NORMAL", "正常"),
  /**
   * 警告.
   */
  WARNING("WARNING", "警告"),
  /**
   * 冻结.
   */
  FREEZE("FREEZE", "冻结"),

  /**
   * 封存.
   */
  ARCHIVE("ARCHIVE", "封存"),

  /**
   * 封禁账号+设备.
   */
  ARCHIVE_DEVICE("ARCHIVE_DEVICE", "封存+设备"),

  /**
   * 设备解封
   */
  UNTIE_DEVICE("UNTIE_DEVICE", "设备解封"),

  /**
   * 账号解封.
   */
  UNTIE_ACOOUNT("UNTIE_DEVICE", "账号解封"),

  /**
   * 设备+账户解封.
   */
  UNTIE_DEVICE_AND_ACCOUNT("UNTIE_DEVICE_AND_ACCOUNT", "设备+账户解封");

  private final String name;

  private final String desc;

  ConsoleAccountStatusEnum(String name, String desc) {
    this.name = name;
    this.desc = desc;
  }

  public boolean eq(ConsoleAccountStatusEnum status) {
    return Objects.equals(status, this);
  }

  public static String getDescValue(String name) {
    return Arrays.stream(ConsoleAccountStatusEnum.values())
        .filter(accountStatusEnum -> Objects.equals(accountStatusEnum.getName(), name))
        .findFirst()
        .map(ConsoleAccountStatusEnum::getDesc)
        .orElse("未知");
  }

  public String getName() {
    return name;
  }

  public String getDesc() {
    return desc;
  }
}
