import axios from 'axios'; import type { XunlianCode } from '../../share/types_stock.ts'; // 训练代码列表响应 interface XunlianCodeListResponse { data: XunlianCode[]; pagination: { current: number; pageSize: number; total: number; totalPages: number; }; } interface XunlianCodeResponse { data: XunlianCode; message?: string; } interface XunlianCodeCreateResponse { message: string; data: XunlianCode; } interface XunlianCodeUpdateResponse { message: string; data: XunlianCode; } interface XunlianCodeDeleteResponse { message: string; id: number; } export const XunlianCodeAPI = { getXunlianCodes: async (params: { page?: number; pageSize?: number; code?: string; stock_name?: string; }): Promise => { try { const response = await axios.get('/xunlian-codes', { params }); return response.data; } catch (error) { throw error; } }, getXunlianCode: async (id: number): Promise => { try { const response = await axios.get(`/xunlian-codes/${id}`); return response.data; } catch (error) { throw error; } }, createXunlianCode: async (data: Partial): Promise => { try { const response = await axios.post('/xunlian-codes', data); return response.data; } catch (error) { throw error; } }, updateXunlianCode: async (id: number, data: Partial): Promise => { try { const response = await axios.put(`/xunlian-codes/${id}`, data); return response.data; } catch (error) { throw error; } }, deleteXunlianCode: async (id: number): Promise => { try { const response = await axios.delete(`/xunlian-codes/${id}`); return response.data; } catch (error) { throw error; } } };