// ============================================================
// Banner 模块 — 首页轮播图 API
// GET /api/v1/banners
// ============================================================

import {get} from '@/shared/services/http';

// ---------- 路由常量 ----------

const BannerUrlObj = {
    list: '/api/v1/creatives',
} as const;

// ---------- 类型 ----------

// ============================================================
// Banner 分类常量
// ============================================================

export const BannerCategoryEnum = {
    Promotion: "promotion",
    Banner: "banner",
} as const;

export type BannerCategoryValue = typeof BannerCategoryEnum[keyof typeof BannerCategoryEnum];

export const BannerCategoryLabelMap: Record<BannerCategoryValue, string> = {
    [BannerCategoryEnum.Promotion]: "推广",
    [BannerCategoryEnum.Banner]: "轮播",
};

/** 单条 Banner */
export interface Banner {
    id: number;
    title: string;
    content: "真人素材提示";
    image_url: string;
    link_url?: string;
    category: BannerCategoryValue;
    vip_level_id?: number;
    sort_order: number;
    is_active: boolean;
    created_by: string;
    created_at: Date;
    updated_at: Date;
}

/** Banner 列表响应 */
export type BannerListResponse = Banner[];

// ---------- API ----------

/**
 * 获取 Banner 轮播图列表
 * GET /api/v1/banners
 */
export function fetchBanners(signal?: AbortSignal): Promise<BannerListResponse> {
    return get<BannerListResponse>(BannerUrlObj.list, undefined, { signal });
}
