package com.czg.product.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.List;

/**
 * 商品销售状态枚举
 *
 * @author tankaikai
 * @since 2025-02-28 17:27
 */
@Getter
@RequiredArgsConstructor
public enum ProductSaleStatusEnum {
    /**
     * 已售罄
     */
    SOLD_OUT("sold_out", "已售罄"),
    /**
     * 在售中
     */
    ON_SALE("on_sale", "在售中"),
    /**
     * 已下架
     */
    OFF_SALE("off_sale", "已下架"),
    ;

    private final String value;
    private final String text;


    public static List<String> getValues() {
        return Arrays.stream(values()).map(ProductSaleStatusEnum::getValue).toList();
    }

    public static String getText(String value) {
        ProductSaleStatusEnum item = Arrays.stream(values()).filter(obj -> value.equals(obj.getValue())).findFirst().orElse(null);
        if (item != null) {
            return item.getText();
        }
        return null;
    }

}
