package com.seer.teach.common.enums;

import lombok.Getter;

/**
 * 配送方式枚举
 */
@Getter
public enum DeliveryTypeEnum {

    /**
     * 商家发货
     */
    MERCHANT_SHIP(0, "商家发货"),

    /**
     * 自提
     */
    PICK_UP(1, "自提");

    private final Integer code;
    private final String description;

    DeliveryTypeEnum(Integer code, String description) {
        this.code = code;
        this.description = description;
    }

    public static DeliveryTypeEnum fromCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (DeliveryTypeEnum deliveryType : DeliveryTypeEnum.values()) {
            if (deliveryType.getCode().equals(code)) {
                return deliveryType;
            }
        }
        return null;
    }
}