package com.srs.common.enums;

/**
 * 销假状态
 */
public enum LeaveCancellationStatus {
    /**
     * 未销假
     */
    NOT_CANCELED(0, "未销假"),
    /**
     * 销假申请中
     */
    CANCEL_REQUESTED(1, "销假申请"),
    /**
     * 已销假
     */
    CANCELED(2, "已销假");

    private int code;
    private String description;

    LeaveCancellationStatus(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    /**
     * 根据code获取枚举值
     * @param code 销假状态码
     * @return 枚举实例
     */
    public static LeaveCancellationStatus fromCode(int code) {
        for (LeaveCancellationStatus status : values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid code for LeaveCancellationStatus: " + code);
    }
}

