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 DistributorProductTypeEnum {

    NO(0, "不参加分销"),
    YES(1, "参加分销"),
    ;

    private Integer type;

    private String name;

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

}
