import { ndmClient, userClient, type ImportMsg, type NdmVideoServerPageQuery, type NdmVideoServerResultVO, type NdmVideoServerSaveVO, type NdmVideoServerUpdateVO, type PageParams, type PageResult, type Station, } from '@/apis'; import { unwrapResponse, unwrapVoidResponse } from '@/utils'; export const pageVideoServerApi = 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/ndmVideoServer/page`; const resp = await client.post>(endpoint, pageQuery, { signal }); const data = unwrapResponse(resp); return data; }; export const detailVideoServerApi = 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/ndmVideoServer/detail`; const resp = await client.get(endpoint, { params: { id }, signal }); const data = unwrapResponse(resp); return data; }; export const saveVideoServerApi = async (saveVO: NdmVideoServerSaveVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmVideoServer`; const resp = await client.post(endpoint, saveVO, { signal }); const data = unwrapResponse(resp); return data; }; export const updateVideoServerApi = async (updateVO: NdmVideoServerUpdateVO, options?: { stationCode?: Station['code']; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmVideoServer`; const resp = await client.put(endpoint, updateVO, { signal }); const data = unwrapResponse(resp); return data; }; export const deleteVideoServerApi = 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/ndmVideoServer`; const resp = await client.delete(endpoint, ids, { signal }); const data = unwrapResponse(resp); return data; }; export const exportVideoServerApi = 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/ndmVideoServer/defaultExportByTemplate`; const resp = await client.post(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal }); const data = unwrapResponse(resp); return data; }; export const importVideoServerApi = 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/ndmVideoServer/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 probeVideoServerApi = 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/ndmVideoServer/probeByIds`; const resp = await client.post(endpoint, ids, { signal }); unwrapVoidResponse(resp); };