| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- 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<XunlianCodeListResponse> => {
- try {
- const response = await axios.get('/xunlian-codes', { params });
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- getXunlianCode: async (id: number): Promise<XunlianCodeResponse> => {
- try {
- const response = await axios.get(`/xunlian-codes/${id}`);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- createXunlianCode: async (data: Partial<XunlianCode>): Promise<XunlianCodeCreateResponse> => {
- try {
- const response = await axios.post('/xunlian-codes', data);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- updateXunlianCode: async (id: number, data: Partial<XunlianCode>): Promise<XunlianCodeUpdateResponse> => {
- try {
- const response = await axios.put(`/xunlian-codes/${id}`, data);
- return response.data;
- } catch (error) {
- throw error;
- }
- },
- deleteXunlianCode: async (id: number): Promise<XunlianCodeDeleteResponse> => {
- try {
- const response = await axios.delete(`/xunlian-codes/${id}`);
- return response.data;
- } catch (error) {
- throw error;
- }
- }
- };
|