import { apiRequest } from "@/shared/api/request";
import { API_OPERATIONS, apiEndpointPath } from "@/shared/api/generated/endpoints";
import type {
  DashboardOverviewDto,
  DashboardUserProfileOverviewDto,
  DashboardUserProfileOverviewQuery
} from "@/shared/api/types";

export function getDashboardOverview(): Promise<DashboardOverviewDto> {
  return apiRequest<DashboardOverviewDto>(apiEndpointPath(API_OPERATIONS.dashboardOverview));
}

export function getDashboardUserProfileOverview(
  query: DashboardUserProfileOverviewQuery
): Promise<DashboardUserProfileOverviewDto> {
  // app_code 明确参与统计聚合；请求层仍会附带 X-App-Code，供后端执行应用数据权限校验。
  return apiRequest<DashboardUserProfileOverviewDto>(apiEndpointPath(API_OPERATIONS.dashboardUserProfileOverview), {
    query: {
      app_code: query.appCode,
      end_ms: query.endMs,
      start_ms: query.startMs,
      stat_tz: query.statTz
    }
  });
}
