import { ndmClient, userClient, type NdmAlarmHostPageQuery, type NdmAlarmHostResultVO, type NdmAlarmHostSaveVO, type NdmAlarmHostUpdateVO, type PageParams, type PageResult, type Station, } from '@/apis'; export const pageAlarmHostApi = async (pageQuery: PageParams, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmAlarmHost/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 detailAlarmHostApi = async (id: string, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmAlarmHost/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 saveAlarmHostApi = async (saveVO: NdmAlarmHostSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmAlarmHost`; 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 updateAlarmHostApi = async (updateVO: NdmAlarmHostUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmAlarmHost`; 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 deleteAlarmHostApi = async (ids: string[], options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmAlarmHost`; const resp = await client.delete(endpoint, ids, { signal }); const [err, data] = resp; if (err) throw err; if (!data) throw new Error(`${data}`); return data; };