package cn.axzo.msg.center.service.enums;

import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

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

/**
 * @description
 *
 * @author cold_blade
 * @date 2023/9/20
 * @version 1.0
 */
@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum IdentityTypeEnum {

    /*人员身份类型*/
    NOT_SUPPORT(0, "NOT_SUPPORT", "无效类型"),
    WORKER(1, "WORKER", "工人"),
    WORKER_LEADER(2, "WORKER_LEADER", "班组长"),
    PRACTITIONER(3, "PRACTITIONER", "从业人员"),
    REGULATOR(4, "REGULATOR", "监管人员"),
    OPERATOR(5, "OPERATOR", "运营人员"),
    ;
    private final Integer code;
    private final String message;
    private final String desc;

    /**
     * 通过code获取对应的枚举实例
     *
     * @param code 身份枚举的编码
     * @return 身份枚举实例 {@code OR} 空
     */
    public static Optional<IdentityTypeEnum> codeOf(Integer code) {
        return Arrays.stream(values())
                .filter(e -> Objects.equals(e.code, code))
                .findFirst();
    }
}
