import { ndmClient, type NdmSwitchPageQuery, type NdmSwitchResultVO, type NdmSwitchSaveVO, type NdmSwitchUpdateVO, type PageParams, type PageResult, type Station } from '@/apis'; export const pageSwitchApi = async (pageQuery: PageParams, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : ndmClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmSwitch/page`; const resp = await client.post>(endpoint, pageQuery, { signal }); const [err, data] = resp; if (err) throw err; if (!data) throw new Error(`${data}`); return data; }; export const detailSwitchApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : ndmClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmSwitch/detail`; const resp = await client.get(endpoint, { params: { id }, signal }); const [err, data] = resp; if (err) throw err; if (!data) throw new Error(`${data}`); return data; }; export const saveSwitchApi = async (saveVO: NdmSwitchSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : ndmClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmSwitch`; const resp = await client.post(endpoint, saveVO, { signal }); const [err, data] = resp; if (err) throw err; if (!data) throw new Error(`${data}`); return data; }; export const updateSwitchApi = async (updateVO: NdmSwitchUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : ndmClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmSwitch`; const resp = await client.put(endpoint, updateVO, { signal }); const [err, data] = resp; if (err) throw err; if (!data) throw new Error(`${data}`); return data; }; export const deleteSwitchApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : ndmClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmSwitch`; const resp = await client.delete(endpoint, ids, { signal }); const [err, data] = resp; if (err) throw err; if (!data) throw new Error(`${data}`); return data; }; export const probeSwitchApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : ndmClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmSwitch/probeByIds`; const resp = await client.post(endpoint, ids, { signal }); const [err] = resp; if (err) throw err; };