package com.ningdatech.pmapi.expert.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author liuxinxin
 * @date 2022/7/26 下午1:40
 * 专家审核申请类型
 */
@AllArgsConstructor
@Getter
public enum ExpertApplyTypeEnum {

    // 专家入库
    EXPERT_STORAGE("expert_storage"),
    // 专家出库
    EXPERT_DELIVERY("expert_delivery"),
    // 专家履职意向加入
    EXPERT_INTENTION_JOIN("expert_intention_join"),
    // 专家履职意向退出
    EXPERT_INTENTION_LEAVE("expert_intention_leave"),
    // 长期请假申请
    LONG_TERM_LEAVE("long_term_leave"),
    // 专家信息修改申请
    EXPERT_INFO_MODIFY("expert_info_modify");

    private final String key;

    public static boolean contains(String key) {
        if (StringUtils.isBlank(key)) {
            return false;
        }
        for (ExpertApplyTypeEnum typeEnum : ExpertApplyTypeEnum.values()) {
            if (typeEnum.key.equals(key)) {
                return true;
            }
        }
        return false;
    }

    public static ExpertApplyTypeEnum of(String key) {
        for (ExpertApplyTypeEnum typeEnum : ExpertApplyTypeEnum.values()) {
            if (typeEnum.key.equals(key)) {
                return typeEnum;
            }
        }
        throw new IllegalArgumentException(String.format("IllegalExpertApplyTypeEnum = %s", key));
    }

}
