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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 轮播展示端，与 {@code cms_home_banner.platform} 存储值一致。
 *
 * @author jeesharp
 * @since 2026-05-08
 */
@Getter
@AllArgsConstructor
public enum HomeBannerPlatformEnum {

    /** 全部端可见 */
    ALL("ALL", "全部端"),

    /** 微信小程序 */
    WECHAT_MINI("WECHAT_MINI", "微信小程序"),

    /** APP */
    APP("APP", "APP"),

    /** H5 */
    H5("H5", "H5");

    private final String value;
    private final String desc;

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

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