package org.wfc.user.domain.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 有效期类型枚举
 * @author: cyc
 * @since: 2024-12-23
 */
@Getter
@AllArgsConstructor
public enum PeriodTypeEnum {

    HOUR(0, "小时"),
    DAY(1, "天"),
    MONTH(2, "月"),
    YEAR(3, "年")
    ;

    private final Integer code;
    private final String desc;

    public static PeriodTypeEnum getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (PeriodTypeEnum periodTypeEnum : PeriodTypeEnum.values()) {
            if (periodTypeEnum.getCode().equals(code)) {
                return periodTypeEnum;
            }
        }
        return null;
    }
}
