package digital.laboratory.platform.inspection.enums;

import lombok.Getter;

/**
 * 任务审核状态
 */
@Getter
public enum TaskTestDataStatus {

    REJECT(-1, "审核审批不通过"),
    WAIT_REVIEW(0, "待审核"),
    REVIEWED(1, "已审核"),
    APPROVED(2, "已审批"),
    UPLOADED(3, "已上传")
    ;
    private int code;
    private String message;

    TaskTestDataStatus(int code, String message) {
        this.code = code;
        this.message = message;
    }

    /**
     * 根据code 值获取状态名称
     * @param code
     * @return
     */
    public static String getStatusNameByCode(int code) {
        for (TaskTestDataStatus status : values()) {
            if (code == status.getCode()) {
                return status.getMessage();
            }
        }
        throw new RuntimeException(String.format("没有获取到code 为 %s相关的状态名", code));
    }

    /***
     * 根据code 获取enum
     * @param code
     * @return
     */
    public static TaskTestDataStatus getEnumByCode(int code) {
        for (TaskTestDataStatus status : values()) {
            if (code == status.getCode()) {
                return status;
            }
        }
        throw new RuntimeException(String.format("没有获取到code 为 %s相关的枚举", code));
    }
}
