refactor(api): ndm-record-check
This commit is contained in:
@@ -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';
|
||||
|
||||
59
src/apis/request/biz/log/ndm-record-check.ts
Normal file
59
src/apis/request/biz/log/ndm-record-check.ts
Normal file
@@ -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<ClientChannel[]>(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<NdmRecordCheck[]>(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<boolean>(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<boolean>(endpoint, dayOffset, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
@@ -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<ClientChannel[]>(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<NdmRecordCheck[]>(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<boolean>(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<boolean>(endpoint, dayOffset, { signal });
|
||||
const [err, data] = resp;
|
||||
if (err || !data) {
|
||||
throw err;
|
||||
}
|
||||
return data;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user