package com.lesingle.creation.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 竞赛状态枚举
 */
@Getter
@AllArgsConstructor
public enum ContestStateEnum {

    UNPUBLISHED("unpublished", "未发布"),
    PUBLISHED("published", "已发布"),
    REGISTERING("registering", "报名中"),
    SUBMITTING("submitting", "作品提交中"),
    REVIEWING("reviewing", "评审中"),
    FINISHED("finished", "已完结");

    private final String code;
    private final String desc;

    public static ContestStateEnum getByCode(String code) {
        if (code == null) {
            return UNPUBLISHED;
        }
        for (ContestStateEnum state : values()) {
            if (state.getCode().equals(code)) {
                return state;
            }
        }
        return UNPUBLISHED;
    }
}
