package co.yixiang.yshop.module.distributor.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

@Getter
@AllArgsConstructor
public enum DistributorLevelTypeEnum {

    P1(1, "一级分销商"),
    P2(2, "二级分销商"),
    ;

    private Integer type;

    private String name;

    public static DistributorLevelTypeEnum toType(Integer type) {
        return Stream.of(DistributorLevelTypeEnum.values())
                .filter(p -> Objects.equals(p.type, type))
                .findAny()
                .orElse(null);
    }

}
