package com.jeesharp.business.modules.mall.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 购物车行选中状态，与 {@code mall_cart_item.selected} 一致。
 *
 * @author jeesharp
 * @since 2026-05-07
 */
@Getter
@AllArgsConstructor
public enum MallCartItemSelectedEnum {

    /** 未选中 */
    UNSELECTED(0, "未选中"),

    /** 已选中 */
    SELECTED(1, "已选中");

    private final Integer value;
    private final String desc;

    public static MallCartItemSelectedEnum fromValue(Integer value) {
        if (value == null) {
            return null;
        }
        for (MallCartItemSelectedEnum e : values()) {
            if (e.value.equals(value)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByValue(Integer value) {
        MallCartItemSelectedEnum e = fromValue(value);
        return e != null ? e.getDesc() : "";
    }
}
