import { ndmClient, userClient, type ClientChannel, type NdmNvrResultVO, type NdmRecordCheck } from '@/apis'; import dayjs from 'dayjs'; export const getChannelListApi = async (ndmNvr: NdmNvrResultVO, options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getChannelList`; const resp = await client.post(endpoint, { code: ndmNvr.gbCode, time: '' }, { signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const getRecordCheckApi = async (ndmNvr: NdmNvrResultVO, lastDays: number, gbCodeList: string[], options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmRecordCheck/getRecordCheckByParentId`; const endDateTime = dayjs(); const startDateTime = endDateTime.subtract(lastDays, 'day'); const start = startDateTime.format('YYYY-MM-DD'); const end = endDateTime.format('YYYY-MM-DD'); const parentId = ndmNvr.gbCode; const resp = await client.post(endpoint, { start, end, parentId, gbCodeList }, { signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const reloadRecordCheckApi = async (channel: ClientChannel, dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadRecordCheckByGbId`; const resp = await client.post(endpoint, { ...channel, dayOffset }, { signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; }; export const reloadAllRecordCheckApi = async (dayOffset: number, options?: { stationCode?: string; signal?: AbortSignal }) => { const { stationCode, signal } = options ?? {}; const client = stationCode ? ndmClient : userClient; const prefix = stationCode ? `/${stationCode}` : ''; const endpoint = `${prefix}/api/ndm/ndmRecordCheck/reloadAllRecordCheck`; const resp = await client.post(endpoint, dayOffset, { signal }); const [err, data] = resp; if (err || !data) { throw err; } return data; };