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

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

/**
 * @author lixiaofei on 2024/06/06 10:27
 */
public enum AccountStatusStrEnum {

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

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

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

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

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

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

  private final String name;

  private final String desc;

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

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

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

  public String getName() {
    return name;
  }

  public String getDesc() {
    return desc;
  }
}
