package com.srs.common.enums;

/**
 * 请假操作类型
 */
public enum OperationType {
    /**
     * 请假申请
     */
    LEAVE_APPLICATION(0, "请假申请"),
    /**
     * 辅导员审批
     */
    TUTOR_APPROVAL(1, "辅导员审批"),
    /**
     * 学生销假申请
     */
    STUDENT_LEAVE_CANCEL_REQUEST(2, "学生销假申请"),
    /**
     * 辅导员核实销假
     */
    TUTOR_LEAVE_CANCEL_VERIFICATION(3, "辅导员核实销假"),
    /**
     * 结束（流程结束）
     */
    END(4, "结束");

    private int code;
    private String description;

    OperationType(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 OperationType fromCode(int code) {
        for (OperationType operationType : values()) {
            if (operationType.getCode() == code) {
                return operationType;
            }
        }
        throw new IllegalArgumentException("Invalid code for OperationType: " + code);
    }
}

