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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 运营弹窗是否允许用户关闭，对应表字段 {@code cfg_operation_popup.closable}。
 *
 * @author jeesharp
 * @since 2026-05-13
 */
@Getter
@AllArgsConstructor
public enum OperationPopupClosableEnum {

    /**
     * 不可关闭
     */
    NO(0, "否"),

    /**
     * 可关闭
     */
    YES(1, "是");

    private final Integer value;

    private final String desc;

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

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