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 ExpertApplyTypeQueryEnum {

    // 专家入库
    EXPERT_STORAGE("expert_storage"),
    // 专家出库
    EXPERT_DELIVERY("expert_delivery"),
    // 专家履职意变更
    EXPERT_INTENTION_CHANGE("expert_intention_change"),
    // 长期请假申请
    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 (ExpertApplyTypeQueryEnum typeEnum : ExpertApplyTypeQueryEnum.values()) {
            if (typeEnum.key.equals(key)) {
                return true;
            }
        }
        return false;
    }

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

}
