From dec1c4ea1780c945edce1e83eecfb2fc5809e9fc Mon Sep 17 00:00:00 2001 From: yangsy Date: Thu, 27 Nov 2025 11:49:57 +0800 Subject: [PATCH] refactor(api): ndm-record-check --- src/apis/request/biz/log/index.ts | 1 + src/apis/request/biz/log/ndm-record-check.ts | 59 ++++++++++++++++++++ src/apis/request/biz/storage/ndm-nvr.ts | 57 ------------------- 3 files changed, 60 insertions(+), 57 deletions(-) create mode 100644 src/apis/request/biz/log/ndm-record-check.ts diff --git a/src/apis/request/biz/log/index.ts b/src/apis/request/biz/log/index.ts index 578a4be..9868bd2 100644 --- a/src/apis/request/biz/log/index.ts +++ b/src/apis/request/biz/log/index.ts @@ -1,5 +1,6 @@ export * from './ndm-call-log'; export * from './ndm-device-alarm-log'; export * from './ndm-icmp-log'; +export * from './ndm-record-check'; export * from './ndm-snmp-log'; export * from './ndm-vimp-log'; diff --git a/src/apis/request/biz/log/ndm-record-check.ts b/src/apis/request/biz/log/ndm-record-check.ts new file mode 100644 index 0000000..9030a0f --- /dev/null +++ b/src/apis/request/biz/log/ndm-record-check.ts @@ -0,0 +1,59 @@ +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; +}; diff --git a/src/apis/request/biz/storage/ndm-nvr.ts b/src/apis/request/biz/storage/ndm-nvr.ts index b89fe62..92f4cdd 100644 --- a/src/apis/request/biz/storage/ndm-nvr.ts +++ b/src/apis/request/biz/storage/ndm-nvr.ts @@ -51,60 +51,3 @@ export const probeNvrApi = async (ids: string[], options?: { stationCode?: strin throw err; } }; - -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; -};