package org.wfc.user.domain.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @description: 流量单位枚举
 * @author: cyc
 * @since: 2025-01-16
 */
@Getter
@AllArgsConstructor
public enum TratticUnitEnum {

    B(0, "B"),
    KB(1, "KB"),
    MB(2, "MB"),
    GB(3, "GB"),
    TB(4, "TB"),
    ;

    private final Integer code;
    private final String desc;

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