69 lines
1.8 KiB
TypeScript
69 lines
1.8 KiB
TypeScript
import { api } from '@/services/api';
|
|
|
|
export type GenerateAiReportParams = {
|
|
date?: string;
|
|
};
|
|
|
|
export type GenerateAiReportResponse = {
|
|
imageUrl: string;
|
|
};
|
|
|
|
/**
|
|
* 调用后端生成 AI 健康报告图片
|
|
*/
|
|
export async function generateAiReport(params: GenerateAiReportParams = {}): Promise<GenerateAiReportResponse> {
|
|
return await api.post<GenerateAiReportResponse>('/users/ai-report', params, {
|
|
// 确保请求体使用 JSON
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
});
|
|
}
|
|
|
|
// 报告状态
|
|
export type AiReportStatus = 'pending' | 'processing' | 'success' | 'failed';
|
|
|
|
// 单条报告记录
|
|
export type AiReportRecord = {
|
|
id: string;
|
|
reportDate: string;
|
|
imageUrl: string;
|
|
status: AiReportStatus;
|
|
createdAt: string;
|
|
};
|
|
|
|
// 历史列表请求参数
|
|
export type GetAiReportHistoryParams = {
|
|
page?: number;
|
|
pageSize?: number;
|
|
startDate?: string;
|
|
endDate?: string;
|
|
status?: AiReportStatus;
|
|
};
|
|
|
|
// 历史列表响应
|
|
export type GetAiReportHistoryResponse = {
|
|
records: AiReportRecord[];
|
|
total: number;
|
|
page: number;
|
|
pageSize: number;
|
|
totalPages: number;
|
|
};
|
|
|
|
/**
|
|
* 获取 AI 健康报告历史列表
|
|
*/
|
|
export async function getAiReportHistory(params: GetAiReportHistoryParams = {}): Promise<GetAiReportHistoryResponse> {
|
|
const searchParams = new URLSearchParams();
|
|
if (params.page) searchParams.set('page', String(params.page));
|
|
if (params.pageSize) searchParams.set('pageSize', String(params.pageSize));
|
|
if (params.startDate) searchParams.set('startDate', params.startDate);
|
|
if (params.endDate) searchParams.set('endDate', params.endDate);
|
|
if (params.status) searchParams.set('status', params.status);
|
|
|
|
const query = searchParams.toString();
|
|
const path = `/users/ai-report/history${query ? `?${query}` : ''}`;
|
|
|
|
return await api.get<GetAiReportHistoryResponse>(path);
|
|
}
|