0b0a060967
- 证书API 500修复: AssessmentCertificate实体注册到app.module.ts - 前端TS错误25个清零: i18n key 17个, 类型定义8个 - i18n补全: 17个缺失key添加到zh/en/ja - KnowledgeFile类型: 添加title, content字段 - importService: 改用apiClient.request替代raw fetch - ModeSelector: 移除jsx prop - questionBankService: .ok -> .status >= 400 - NotebookDetailView: .filter -> .items.filter - ImportTasksDrawer: tasks.items提取 - API端点审计: 16/16通过 - 数据库Schema审计: 25表288列一致 - AGENTS.md更新
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import { apiClient } from './apiClient';
|
|
|
|
export interface ImportTask {
|
|
id: string;
|
|
sourcePath: string;
|
|
targetGroupId?: string;
|
|
targetGroupName?: string;
|
|
scheduledAt?: string;
|
|
status: 'PENDING' | 'PROCESSING' | 'COMPLETED' | 'FAILED';
|
|
logs?: string;
|
|
embeddingModelId?: string;
|
|
chunkSize?: number;
|
|
chunkOverlap?: number;
|
|
mode?: string;
|
|
createdAt: string;
|
|
}
|
|
|
|
export const importService = {
|
|
create: async (authToken: string, data: {
|
|
sourcePath: string;
|
|
targetGroupId?: string;
|
|
targetGroupName?: string;
|
|
embeddingModelId: string;
|
|
scheduledAt?: string;
|
|
chunkSize?: number;
|
|
chunkOverlap?: number;
|
|
mode?: string;
|
|
}): Promise<ImportTask> => {
|
|
const response = await apiClient.request('/import-tasks', {
|
|
method: 'POST',
|
|
body: JSON.stringify(data)
|
|
});
|
|
if (!response.ok) throw new Error('Failed to create import task');
|
|
return response.json();
|
|
},
|
|
|
|
getAll: async (authToken: string, options: { page?: number; limit?: number } = {}): Promise<{ items: ImportTask[]; total: number; page: number; limit: number }> => {
|
|
const queryParams = new URLSearchParams();
|
|
if (options.page) queryParams.append('page', options.page.toString());
|
|
if (options.limit) queryParams.append('limit', options.limit.toString());
|
|
|
|
const queryString = queryParams.toString();
|
|
const url = `/import-tasks${queryString ? `?${queryString}` : ''}`;
|
|
|
|
const response = await apiClient.request(url, {});
|
|
if (!response.ok) throw new Error('Failed to fetch import tasks');
|
|
return response.json();
|
|
},
|
|
|
|
delete: async (token: string, id: string): Promise<void> => {
|
|
const response = await apiClient.request(`/import-tasks/${id}`, {
|
|
method: 'DELETE',
|
|
headers: {
|
|
'Authorization': `Bearer ${token}`
|
|
}
|
|
});
|
|
if (!response.ok) throw new Error('Failed to delete import task');
|
|
}
|
|
};
|