/**
 * @description 轮播图相关API
 * @author yslg
 * @since 2025-10-15
 */

import { api } from '@/apis/index';
import type { Banner, Resource, ResultDomain } from '@/types';

/**
 * 轮播图API服务
 */
export const bannerApi = {
  /**
   * 获取轮播组件数据
   * @returns Promise<ResultDomain<Banner>>
   */
  async getBannerList(): Promise<ResultDomain<Banner>> {
    const response = await api.get<Banner>('/homepage/banner/list');
    return response.data;
  },

  /**
   * 点击轮播跳转新闻详情
   * @param bannerID Banner ID
   * @returns Promise<ResultDomain<Resource>>
   */
  async getBannerNewsDetail(bannerID: string): Promise<ResultDomain<Resource>> {
    const response = await api.get<Resource>(`/homepage/banner/click/${bannerID}`);
    return response.data;
  },

  /**
   * 获取活跃轮播列表
   * @returns Promise<ResultDomain<Banner>>
   */
  async getActiveBanners(): Promise<ResultDomain<Banner>> {
    const response = await api.get<Banner>('/homepage/banner/active');
    return response.data;
  }
};
