/**
 * 报告管理 API 接口
 *
 * @module api/reports
 * @author czj
 * @date 2026-07-09
 */

import request from '@/utils/request'

/**
 * 报告管理 API 服务
 */
export const reportApi = {
  /**
   * 获取报告列表（已完成的执行记录）
   */
  async list(params?: { skip?: number; limit?: number; case_type?: string }): Promise<{ total: number; items: any[] }> {
    const response = await request.get('/api/reports/list', { params })
    return response as any
  },

  /**
   * 生成报告（返回 HTML 内容）
   */
  generateUrl(executionId: string): string {
    return `/api/reports/generate/${executionId}`
  },

  /**
   * 导出报告为文件
   */
  async export(executionId: string): Promise<{ file_path: string; message: string }> {
    const response = await request.post(`/api/reports/export/${executionId}`)
    return response as any
  },

  /**
   * 下载报告
   */
  downloadUrl(executionId: string): string {
    return `/api/reports/download/${executionId}`
  },
}