package com.snack.server.module.category.enums;

import lombok.Getter;

import java.util.Arrays;

/**
 * 分类层级
 */
@Getter
public enum CategoryLevelEnum {

    LEVEL_1(1, "一级分类"),
    LEVEL_2(2, "二级分类"),
    LEVEL_3(3, "三级分类");

    private final Integer code;
    private final String desc;

    CategoryLevelEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static CategoryLevelEnum of(Integer code) {
        return Arrays.stream(values())
                .filter(e -> e.code.equals(code))
                .findFirst()
                .orElse(null);
    }
}
