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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 轮播展示位置，与 {@code cms_home_banner.banner_position} 存储值一致。
 *
 * @author jeesharp
 * @since 2026-05-13
 */
@Getter
@AllArgsConstructor
public enum HomeBannerPositionEnum {

    /** 小程序首页等 */
    HOME("HOME", "首页"),

    /** 商城页等 */
    MALL("MALL", "商城"),

    /** 美食餐饮列表页 */
    FOOD("FOOD", "美食餐饮");

    private final String value;
    private final String desc;

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

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