package com.ff.base.enums;


import com.ff.base.exception.base.BaseException;
import com.ff.base.utils.MessageUtils;
import lombok.Getter;

/**
 * 时间周期类型
 *
 * @author shang
 */
@Getter
public enum TimePeriodType {
    TimePeriodType_1(1, "今日"),
    TimePeriodType_2(2, "昨日"),
    TimePeriodType_3(3, "本周"),
    TimePeriodType_4(4, "上周"),
    TimePeriodType_5(5, "本月"),
    TimePeriodType_6(6, "上月"),
    TimePeriodType_7(7, "全部"),
    TimePeriodType_8(8, "自定义");

    private final Integer code;
    private final String info;

    TimePeriodType(Integer code, String info)
    {
        this.code = code;
        this.info = info;
    }

    public static TimePeriodType getTimePeriodTypeByCode(Integer code)
    {
        for (TimePeriodType item : TimePeriodType.values()) {
            if(item.getCode().equals(code)) {
                return item;
            }
        }
        throw new BaseException(MessageUtils.message("agent.timeperiodtype.enum.not.exists"));
    }
}
