package cn.reghao.tnb.file.app.zjob.model.constant;

import java.util.HashMap;
import java.util.Map;

/**
 * @author reghao
 * @date 2024-12-04 14:07:27
 */
public enum JobStatus {
    Prepare(1, "准备执行"),
    Running(2, "正在执行"),
    Success(3, "执行成功"),
    Fail(4, "执行失败");

    private final int code;
    private final String desc;
    private static Map<Integer, String> descMap = new HashMap<>();
    static {
        for (JobStatus type : JobStatus.values()) {
            descMap.put(type.code, type.desc);
        }
    }

    JobStatus(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public String getName() {
        return this.name();
    }

    /**
     * 提供给 @ValidEnum 调用
     *
     * @param
     * @return
     * @date 2023-10-11 14:44:42
     */
    public int getValue() {
        return this.code;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    public static String getDescByCode(int code) {
        return descMap.get(code);
    }
}
