package com.ningdatech.pmapi.leave.entity.enumeration;

import lombok.Getter;

import java.util.Arrays;

/**
 * <p>
 * LeaveType-请假类型
 * </p>
 *
 * @author WendyYang
 * @since 10:23 2022/8/11
 */
@Getter
public enum LeaveTypeEnum {

    TEMPORARY(3, "临时请假"),
    LONG_TERM(1, "长期请假"),
    FIXED_TERM(2, "固定时段请假");

    private final Integer code;
    private final String name;

    public boolean eq(Integer code) {
        return this.getCode().equals(code);
    }

    LeaveTypeEnum(Integer code, String name) {
        this.code = code;
        this.name = name;
    }

    public static LeaveTypeEnum getByCode(Integer code) {
        return Arrays.stream(values())
                .filter(w -> w.getCode().equals(code))
                .findFirst()
                .orElseThrow(() -> new IllegalArgumentException("无效的请假类型"));
    }

}
