feat(ai报告): 新增AI健康报告画廊功能,支持报告生成、保存与分享
This commit is contained in:
68
services/aiReport.ts
Normal file
68
services/aiReport.ts
Normal file
@@ -0,0 +1,68 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user