searchHistoryService.ts 913 B

1234567891011121314151617181920212223242526272829303132
  1. import { SearchHistoryItem, SearchHistoryDetail } from '../types';
  2. import { apiClient } from './apiClient';
  3. export const searchHistoryService = {
  4. async getHistories(page: number = 1, limit: number = 20): Promise<{
  5. histories: SearchHistoryItem[];
  6. total: number;
  7. page: number;
  8. limit: number;
  9. }> {
  10. const { data } = await apiClient.get(`/search-history?page=${page}&limit=${limit}`);
  11. return data;
  12. },
  13. async getHistoryDetail(id: string): Promise<SearchHistoryDetail> {
  14. const { data } = await apiClient.get(`/search-history/${id}`);
  15. return data;
  16. },
  17. async createHistory(title: string, selectedGroups?: string[]): Promise<{ id: string }> {
  18. const { data } = await apiClient.post(`/search-history`, { title, selectedGroups });
  19. return data;
  20. },
  21. async deleteHistory(id: string): Promise<void> {
  22. await apiClient.delete(`/search-history/${id}`);
  23. },
  24. };