package top.tqx.demo_1.enums;

/**
 * 文件处理流程状态枚举
 * 用于跟踪从文件上传到题目生成的完整流程
 */
public enum FileProcessStepStatus {
    
    UPLOADED("UPLOADED", "文件已上传", 1),
    VECTORIZING("VECTORIZING", "正在向量化", 2),
    VECTORIZED("VECTORIZED", "向量化完成", 3),
    VECTORIZE_FAILED("VECTORIZE_FAILED", "向量化失败", 4),
    EXAM_GENERATING("EXAM_GENERATING", "正在生成题目", 5),
    EXAM_GENERATED("EXAM_GENERATED", "题目生成完成", 6),
    EXAM_GENERATE_FAILED("EXAM_GENERATE_FAILED", "题目生成失败", 7),
    COMPLETED("COMPLETED", "全部流程完成", 8);
    
    private final String code;
    private final String description;
    private final int order;
    
    FileProcessStepStatus(String code, String description, int order) {
        this.code = code;
        this.description = description;
        this.order = order;
    }
    
    public String getCode() {
        return code;
    }
    
    public String getDescription() {
        return description;
    }
    
    public int getOrder() {
        return order;
    }
    
    public static FileProcessStepStatus fromCode(String code) {
        for (FileProcessStepStatus status : values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        return null;
    }
    
    public boolean isFailed() {
        return this == VECTORIZE_FAILED || this == EXAM_GENERATE_FAILED;
    }
    
    public boolean isCompleted() {
        return this == COMPLETED;
    }
}
