package com.inspect.base.core.enums;

import lombok.Getter;

@Getter
public enum TaskStatus {
    DONE("1", "已经执行", 5),
    RUNNING("2", "正在执行", 0),
    PAUSED("3", "暂停执行", 1),
    HALTED("4", "终止执行", 3),
    PENDING("5", "尚未执行", 4),
    EXPIRED("6", "超过期限", 2);

    private final String code;
    private final String info;
    // 状态优先级
    private final Integer priority;

    TaskStatus(String code, String info, Integer priority) {
        this.code = code;
        this.info = info;
        this.priority = priority;
    }

    public static TaskStatus fromCode(String code) {
        if (code == null) {
            return null;
        }
        for (TaskStatus s : values()) {
            if (s.code.equals(code)) {
                return s;
            }
        }
        return null;
    }
}
