import type {
  LogDetailResponse,
  LogListParams,
  LogListResponse,
} from '@/pages/LogAudit/data.d';
import { request } from '@umijs/max';

/** 获取日志列表 GET /api/logs */
export async function queryLogs(
  params: LogListParams,
): Promise<LogListResponse> {
  return request<LogListResponse>('/api/logs', {
    method: 'GET',
    params,
  });
}

/** 获取日志详情 GET /api/logs/:id */
export async function getLogDetail(id: string): Promise<LogDetailResponse> {
  return request<LogDetailResponse>(`/api/logs/${id}`, {
    method: 'GET',
  });
}

/** 导出日志 POST /api/logs/export */
export async function exportLogs(params: LogListParams): Promise<Blob> {
  return request<Blob>('/api/logs/export', {
    method: 'POST',
    data: params,
    responseType: 'blob',
    // 不处理响应，直接返回 blob 用于下载
    skipErrorHandler: true,
  });
}
