package com.red.circle.other.domain.game;

import lombok.Getter;

/**
 * 游戏排行榜周期类型.
 *
 * @author system
 */
@Getter
public enum GameRankingPeriodType {

    /**
     * 全部时间
     */
    ALL("ALL", "全部"),

    /**
     * 本周
     */
    WEEK("WEEK", "本周"),

    /**
     * 本月
     */
    MONTH("MONTH", "本月");

    private final String code;
    private final String name;

    GameRankingPeriodType(String code, String name) {
        this.code = code;
        this.name = name;
    }

    /**
     * 根据 code 获取枚举.
     */
    public static GameRankingPeriodType fromCode(String code) {
        for (GameRankingPeriodType type : values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        return ALL;
    }
}
