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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 运营弹窗展示方式，对应表字段 {@code cfg_operation_popup.display_mode}。
 */
@Getter
@AllArgsConstructor
public enum OperationPopupDisplayModeEnum {

    IMAGE_H("IMAGE_H", "横版海报"),
    IMAGE_V("IMAGE_V", "竖版纯图"),
    CARD("CARD", "图文卡片"),
    COUPON_PACK("COUPON_PACK", "券包到账"),
    ACTIVITY("ACTIVITY", "营销活动");

    private final String value;

    private final String desc;

    public static OperationPopupDisplayModeEnum fromValue(String value) {
        if (value == null || value.isBlank()) {
            return IMAGE_H;
        }
        for (OperationPopupDisplayModeEnum e : values()) {
            if (e.value.equalsIgnoreCase(value.trim())) {
                return e;
            }
        }
        return null;
    }

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

    public boolean requiresImage() {
        return this == IMAGE_H || this == IMAGE_V;
    }
}
