/**
 * 仪表盘相关API
 */

import { USE_MOCK } from '@/utils/config';
import { mockDashboardData } from '@/mock';

/**
 * 获取仪表盘统计数据
 */
export async function getDashboardData(): Promise<any> {
  if (USE_MOCK) {
    return Promise.resolve(mockDashboardData);
  }
  
  const { get } = await import('@/utils/request');
  return get('/dashboard/stats');
}

/**
 * 获取订单趋势数据
 */
export async function getOrderTrend(days: number = 7): Promise<any[]> {
  if (USE_MOCK) {
    return Promise.resolve(mockDashboardData.orderTrend);
  }
  
  const { get } = await import('@/utils/request');
  return get('/dashboard/order-trend', { days });
}

/**
 * 获取热销商品数据
 */
export async function getHotProducts(limit: number = 10): Promise<any[]> {
  if (USE_MOCK) {
    return Promise.resolve(mockDashboardData.hotProducts.slice(0, limit));
  }
  
  const { get } = await import('@/utils/request');
  return get('/dashboard/hot-products', { limit });
}
