0a9588abb7
- 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
32 lines
913 B
TypeScript
32 lines
913 B
TypeScript
import { SearchHistoryItem, SearchHistoryDetail } from '../types';
|
|
import { apiClient } from './apiClient';
|
|
|
|
export const searchHistoryService = {
|
|
|
|
async getHistories(page: number = 1, limit: number = 20): Promise<{
|
|
histories: SearchHistoryItem[];
|
|
total: number;
|
|
page: number;
|
|
limit: number;
|
|
}> {
|
|
const { data } = await apiClient.get(`/search-history?page=${page}&limit=${limit}`);
|
|
return data;
|
|
},
|
|
|
|
|
|
async getHistoryDetail(id: string): Promise<SearchHistoryDetail> {
|
|
const { data } = await apiClient.get(`/search-history/${id}`);
|
|
return data;
|
|
},
|
|
|
|
|
|
async createHistory(title: string, selectedGroups?: string[]): Promise<{ id: string }> {
|
|
const { data } = await apiClient.post(`/search-history`, { title, selectedGroups });
|
|
return data;
|
|
},
|
|
|
|
|
|
async deleteHistory(id: string): Promise<void> {
|
|
await apiClient.delete(`/search-history/${id}`);
|
|
},
|
|
}; |