package com.ruoyi.common.core.domain.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
 * @author caifc
 * @date 2021-10-22 17:19
 */
@Getter
@AllArgsConstructor
public enum WarehouseEnum {

    // 计算入库时间区间类型

    BY_YEAR("year", "按照年"),
    BY_MONTH("month", "按照月"),
    BY_WEEK("week", "按照周"),

    BONDED("0", "保税"),
    NOT_BONDED("1", "非保税"),
    ;

    private final String type;
    private final String name;

    public static WarehouseEnum fromType(String tp) {
        for (WarehouseEnum type : WarehouseEnum.values()) {
            if (Objects.equals(type.getType(), tp)) {
                return type;
            }
        }
        throw new IllegalArgumentException("warehouse type not exist");
    }

}
