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

import lombok.Getter;

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

/**
 * 审批状态.
 *
 * @author pengliang on 2020/4/22 17:28
 */
@Getter
public enum ApprovalStatusEnum {
  /**
   * 默认,未操作.
   */
  NONE("未操作"),
  /**
   * 待审核.
   */
  PENDING("待审核"),
  /**
   * 通过.
   */
  PASS("审核通过"),
  /**
   * 不通过.
   */
  NOT_PASS("审核不通过");


  private final String desc;

  ApprovalStatusEnum(String desc) {
    this.desc = desc;
  }

    public boolean eq(String name) {
    return Objects.equals(this.name(), name);
  }

  public static String getDescValue(String name) {
    return Arrays.stream(ApprovalStatusEnum.values())
        .filter(approvalEnum -> Objects.equals(approvalEnum.name(), name))
        .findFirst()
        .map(ApprovalStatusEnum::getDesc)
        .orElse("未定义");
  }

  public static ApprovalStatusEnum getApprovalVal(String val) {
    for (ApprovalStatusEnum ele : values()) {
      if(ele.name().equals(val)) return ele;
    }
    return null;
  }
}
