feat: get alarms from all stations
This commit is contained in:
@@ -1,10 +1,24 @@
|
||||
import type { PageParams, PageResult } from '@/apis/models/base/page';
|
||||
import type { NdmDeviceAlarmLogPageQuery, NdmDeviceAlarmLogResultVO } from '@/apis/models/device/alarm/ndm-device-alarm-log';
|
||||
|
||||
import { ndmClient } from '@/apis/client';
|
||||
import { ndmClient, userClient } from '@/apis/client';
|
||||
|
||||
export const postNdmDeviceAlarmLogPage = async (stationCode: string, pageQuery: PageParams<NdmDeviceAlarmLogPageQuery>) => {
|
||||
const prefix = stationCode ? `/${stationCode}` : '';
|
||||
const resp = await ndmClient.post<PageResult<NdmDeviceAlarmLogResultVO>>(`${prefix}/api/ndm/ndmDeviceAlarmLog/page`, pageQuery);
|
||||
return resp;
|
||||
const endpoint = '/api/ndm/ndmDeviceAlarmLog/page';
|
||||
// 如果车站编码为空,则通过用户API客户端发送请求
|
||||
if (!stationCode) {
|
||||
const resp = await userClient.post<PageResult<NdmDeviceAlarmLogResultVO>>(endpoint, pageQuery);
|
||||
const [err, alarmData] = resp;
|
||||
if (err || !alarmData) {
|
||||
throw err;
|
||||
}
|
||||
return alarmData;
|
||||
}
|
||||
// 如果车站编码不为空,则通过网管API客户端发送请求
|
||||
const resp = await ndmClient.post<PageResult<NdmDeviceAlarmLogResultVO>>(`/${stationCode}${endpoint}`, pageQuery);
|
||||
const [err, alarmData] = resp;
|
||||
if (err || !alarmData) {
|
||||
throw err;
|
||||
}
|
||||
return alarmData;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user