package com.inspect.calender.enums;

import lombok.Getter;

/**
 * 任务状态枚举类
 */
@Getter
public enum TaskStateEnum {
    // 已执行
    EXECUTED(1, "executed"),
    // 执行中
    EXECUTING(2, "executing"),
    // 已暂停
    PAUSED(3, "paused"),
    // 已终止
    TERMINATE(4, "terminate"),
    // 待执行
    PENDING(5, "pending"),
    // 已超期
    EXCEEDED(6, "exceeded");

    private final int code;
    private final String status;

    TaskStateEnum(int code, String status) {
        this.code = code;
        this.status = status;
    }

    public static String getByCode(int code) {
        for (TaskStateEnum value : values()) {
            if (value.code == code) {
                return value.status;
            }
        }
        return null;
    }
}
