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:
Developer
2026-04-23 17:19:11 +08:00
commit 0a9588abb7
492 changed files with 112453 additions and 0 deletions
+41
View File
@@ -0,0 +1,41 @@
export interface RagSearchResult {
content: string;
fileName: string;
score: number;
chunkIndex: number;
}
export interface RagResponse {
searchResults: RagSearchResult[];
sources: string[];
ragPrompt: string;
hasRelevantContent: boolean;
}
export const ragService = {
async search(query: string, settings: any, authToken: string): Promise<RagResponse> {
try {
const response = await fetch('/api/knowledge-bases/rag-search', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${authToken}`,
},
body: JSON.stringify({ query, settings }),
});
if (!response.ok) {
const errorData = await response.text();
console.error('RAG search error:', response.status, errorData);
throw new Error(`RAG search failed: ${response.status} - ${errorData}`);
}
const result = await response.json();
return result;
} catch (error) {
console.error('RAG service error:', error);
throw error;
}
},
};