Files
ndm-web-client/src/apis/request/biz/log/ndm-device-alarm-log.ts
2025-11-22 01:46:16 +08:00

41 lines
1.9 KiB
TypeScript

import { ndmClient, userClient, type NdmDeviceAlarmLogPageQuery, type NdmDeviceAlarmLogResultVO, type NdmDeviceAlarmLogUpdateVO, type PageParams, type PageResult } from '@/apis';
export const pageDeviceAlarmLogApi = async (pageQuery: PageParams<NdmDeviceAlarmLogPageQuery>, options?: { stationCode?: string; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog/page`;
const resp = await client.post<PageResult<NdmDeviceAlarmLogResultVO>>(endpoint, pageQuery, { signal });
const [err, data] = resp;
if (err || !data) {
throw err;
}
return data;
};
export const updateDeviceAlarmLogApi = async (updateVO: NdmDeviceAlarmLogUpdateVO, options?: { stationCode?: string; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog`;
const resp = await client.put<NdmDeviceAlarmLogResultVO>(endpoint, updateVO, { signal });
const [err, data] = resp;
if (err || !data) {
throw err;
}
return data;
};
export const exportDeviceAlarmLogApi = async (pageQuery: PageParams<NdmDeviceAlarmLogPageQuery>, options?: { stationCode?: string; signal?: AbortSignal }) => {
const { stationCode, signal } = options ?? {};
const client = stationCode ? ndmClient : userClient;
const prefix = stationCode ? `/${stationCode}` : '';
const endpoint = `${prefix}/api/ndm/ndmDeviceAlarmLog/defaultExportByTemplate`;
const resp = await client.post<BlobPart>(endpoint, pageQuery, { responseType: 'blob', retRaw: true, signal });
const [err, data] = resp;
if (err || !data) {
throw err;
}
return data;
};