import { ndmClient, userClient, type ImportMsg, type NdmNvrPageQuery, type NdmNvrResultVO, type NdmNvrSaveVO, type NdmNvrUpdateVO, type PageParams, type PageResult, type Station } from '@/apis'; import { unwrapResponse } from '@/utils'; export const pageNvrPageApi = 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/ndmNvr/page`; const resp = await client.post>(endpoint, pageQuery, { signal }); const data = unwrapResponse(resp); return data; }; export const detailNvrApi = 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/ndmNvr/detail`; const resp = await client.get(endpoint, { params: { id }, signal }); const data = unwrapResponse(resp); return data; }; export const saveNvrApi = async (saveVO: NdmNvrSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmNvr`; const resp = await client.post(endpoint, saveVO, { signal }); const data = unwrapResponse(resp); return data; }; export const updateNvrApi = async (updateVO: NdmNvrUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmNvr`; const resp = await client.put(endpoint, updateVO, { signal }); const data = unwrapResponse(resp); return data; }; export const deleteNvrApi = 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/ndmNvr`; const resp = await client.delete(endpoint, ids, { signal }); const data = unwrapResponse(resp); return data; }; export const exportNvrApi = 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/ndmNvr/defaultExportByTemplate`; const resp = await client.post(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal }); const data = unwrapResponse(resp); return data; }; export const importNvrApi = async (file: File, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmNvr/importReturnMsg`; const formData = new FormData(); formData.append('file', file); const resp = await client.post(endpoint, formData, { signal, upload: true }); const data = unwrapResponse(resp); return data; }; export const probeNvrApi = 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/ndmNvr/probeByIds`; const resp = await client.post(endpoint, ids, { signal }); unwrapResponse(resp); }; export const syncNvrChannelsApi = async (options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmNvr/syncNvrChannels`; const resp = await client.get(endpoint, { signal }); unwrapResponse(resp); };