/**
 * @description 推荐相关API
 * @author yslg
 * @since 2025-10-15
 */

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

/**
 * 推荐API服务
 */
export const recommendApi = {
  /**
   * 获取TOP资源推荐列表
   * @returns Promise<ResultDomain<Resource>>
   */
  async getTopRecommendList(): Promise<ResultDomain<Resource>> {
    const response = await api.get<Resource>('/homepage/recommend/top-list');
    return response.data;
  },

  /**
   * 后台调控展示顺序
   * @param orderData 排序数据
   * @returns Promise<ResultDomain<boolean>>
   */
  async updateRecommendOrder(orderData: any): Promise<ResultDomain<boolean>> {
    const response = await api.put<boolean>('/homepage/recommend/order', orderData);
    return response.data;
  },

  /**
   * 获取高热度新闻
   * @param limit 限制数量
   * @returns Promise<ResultDomain<Resource>>
   */
  async getHotNews(limit?: number): Promise<ResultDomain<Resource>> {
    const response = await api.get<Resource>('/homepage/recommend/hot-news', { limit });
    return response.data;
  }
};
