feat: implement QuestionBank CRUD with pagination and template query
- Add pagination support to findAll (page, limit query params) - Add findByTemplateId method to service - Add GET /by-template/:templateId endpoint to controller - Service already includes CRUD for QuestionBank and QuestionBankItem
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { PDFStatus } from '../types';
|
||||
import { apiClient } from './apiClient';
|
||||
|
||||
export const pdfPreviewService = {
|
||||
|
||||
async getPDFUrl(fileId: string): Promise<{ url: string }> {
|
||||
const { data } = await apiClient.get<{ url: string }>(`/knowledge-bases/${fileId}/pdf-url`);
|
||||
return data;
|
||||
},
|
||||
|
||||
|
||||
async getPDFStatus(fileId: string): Promise<PDFStatus> {
|
||||
const { data } = await apiClient.get<PDFStatus>(`/knowledge-bases/${fileId}/pdf-status`);
|
||||
return data;
|
||||
},
|
||||
|
||||
|
||||
async preloadPDF(fileId: string, force: boolean = false): Promise<void> {
|
||||
try {
|
||||
const url = `/knowledge-bases/${fileId}/pdf-url` + (force ? '?force=true' : '');
|
||||
const response = await apiClient.request(url, {
|
||||
method: 'GET',
|
||||
signal: AbortSignal.timeout(30000), // Increase timeout for conversion
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
console.log('PDF already exists or conversion completed');
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.log('PDF conversion triggered:', error.message);
|
||||
}
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user