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

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

/**
 * 操作用户类型.
 *
 * @author pengliang on 2022/12/9
 */
public enum OpUserType {

  /**
   * app用户.
   */
  APP(0),

  /**
   * 后台管理用户.
   */
  BACK(1);

  OpUserType(int type) {
    this.type = type;
  }

  private final int type;

  public int getType() {
    return type;
  }

  public boolean eq(int val) {
    return Objects.equals(val, this.type);
  }

  public static OpUserType toEnum(Integer val) {
    return Arrays.stream(OpUserType.values()).filter(item -> Objects.equals(item.type, val))
        .findFirst().orElse(APP);
  }
}
