import { ndmClient, userClient, type NdmCameraPageQuery, type NdmCameraResultVO, type NdmCameraUpdateVO, type PageParams, type PageResult, type SnapResult } from '@/apis'; export const pageCameraApi = async (pageQuery: PageParams, options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmCamera/page`; const resp = await client.post>(endpoint, pageQuery, { signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const detailCameraApi = async (id: string, optioins?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = optioins ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmCamera/detail`; const resp = await client.get(endpoint, { params: { id }, signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const updateCameraApi = async (updateVO: NdmCameraUpdateVO, options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmCamera`; const resp = await client.put(endpoint, updateVO, { signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const getCameraSnapApi = async (deviceId: string, options?: { signal?: AbortSignal }) => { const { signal } = options ?? {}; const endpoint = '/api/ndm/ndmCamera/getSnapByDeviceId'; const resp = await ndmClient.get(endpoint, { params: { deviceId }, signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const syncCameraApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmCamera/syncCamera`; const resp = await client.get(endpoint, { signal }); const [err] = resp; if (err) { throw err; } };