package jnpf.enums.cultivate.v2;

import lombok.Getter;

/**
 * 学习任务状态枚举 
 * 0-未发布，1-未开始，2-进行中，3-已结束
 *
 * @author admin
 * @create 2026-03-27
 */
@Getter
public enum LearnTaskStatusEnum {

    /** 未发布 */
    UNPUBLISHED(0, "未发布"),

    /** 未开始 */
    NOT_STARTED(1, "未开始"),

    /** 进行中 */
    IN_PROGRESS(2, "进行中"),

    /** 已结束 */
    FINISHED(3, "已结束"),
    ;

    private final Integer code;
    private final String description;

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

    public static LearnTaskStatusEnum getByCode(Integer code) {
        for (LearnTaskStatusEnum statusEnum : values()) {
            if (statusEnum.getCode().equals(code)) {
                return statusEnum;
            }
        }
        return null;
    }

    public static String getDescription(Integer code) {
        LearnTaskStatusEnum statusEnum = getByCode(code);
        return statusEnum != null ? statusEnum.getDescription() : null;
    }
}
