package com.lesingle.edu.common.enums;

import lombok.Getter;

/**
 * 任务完成情况状态枚举
 */
@Getter
public enum TaskCompletionStatus {

    PENDING("PENDING", "待提交"),
    SUBMITTED("SUBMITTED", "已提交"),
    REVIEWED("REVIEWED", "已评价"),
    COMPLETED("completed", "已完成"); // 兼容旧数据

    private final String code;
    private final String description;

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

    public static TaskCompletionStatus fromCode(String code) {
        if (code == null) {
            return PENDING;
        }
        for (TaskCompletionStatus status : values()) {
            if (status.getCode().equalsIgnoreCase(code)) {
                return status;
            }
        }
        return PENDING;
    }

    /**
     * 获取状态描述文本
     */
    public String getDescription() {
        return this.description;
    }

}
