package com.starry.admin.modules.shop.module.enums;

import java.util.Arrays;
import java.util.Optional;
import lombok.Getter;

/**
 * 优惠券上下架状态
 */
@Getter
public enum CouponOnlineState {
    OFFLINE("0"),
    ONLINE("1");

    private final String code;

    CouponOnlineState(String code) {
        this.code = code;
    }

    public static Optional<CouponOnlineState> fromCode(String code) {
        return Arrays.stream(values()).filter(item -> item.code.equals(code)).findFirst();
    }
}
