package com.mvc.constant;

/**
 * 任务状态
 */
public enum TaskStatus {
    NOT_EXECUTED("0", "未执行"),
    EXECUTED("1", "已执行"),
    CANCELLED("2", "已取消"),
    UNKNOWN("9", "未知");

    private final String code;
    private final String description;

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

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static TaskStatus fromCode(String code) {
        for (TaskStatus status : TaskStatus.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return UNKNOWN;
    }
}
