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

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 轮播跳转业务场景历史枚举（未部署 {@code cfg_biz_scene} 时的回退）。
 * <p>生产环境请以注册表 {@code scene_code} + {@code ext_json.mobile} 为准，见 {@code BizSceneApi}。</p>
 *
 * @author jeesharp
 * @since 2026-07-03
 * @deprecated 由 {@code cfg_biz_scene} 与 {@link com.jeesharp.business.modules.common.api.BizSceneApi} 承接；仅保留未落库时的兼容回退。
 */
@Deprecated
@Getter
@AllArgsConstructor
public enum HomeBannerBizTypeEnum {

    FOOD_RESTAURANT("FOOD_RESTAURANT", "美食门店",
            "/package-views/pages/food/detail", "id",
            "/package-views/pages/food/index"),
    MALL_SPU("MALL_SPU", "商城商品",
            "/package-views/pages/product/detail", "id",
            "/package-views/pages/product/mall"),
    COUPON("COUPON", "优惠券",
            "/package-views/pages/coupon/detail", "id",
            "/package-views/pages/coupon/index"),
    HOME_GRID_INTRO("HOME_GRID_INTRO", "宫格介绍",
            "/package-views/pages/homeGridIntro/detail", "id",
            null),
    MARKETING("MARKETING", "营销推广",
            "/package-views/pages/marketing/detail", "id",
            "/package-views/pages/marketing/index");

    private final String code;
    private final String desc;
    /** 详情页路径（不含 query） */
    private final String detailPath;
    /** 详情页主键 query 参数名 */
    private final String detailIdParam;
    /** 列表/频道页路径，无列表则为 null */
    private final String listPath;

    public static HomeBannerBizTypeEnum fromCode(String code) {
        if (code == null || code.isBlank()) {
            return null;
        }
        String c = code.trim();
        for (HomeBannerBizTypeEnum e : values()) {
            if (e.code.equalsIgnoreCase(c)) {
                return e;
            }
        }
        return null;
    }

    public static String getDescByCode(String code) {
        HomeBannerBizTypeEnum e = fromCode(code);
        return e != null ? e.getDesc() : "";
    }
}
