refactor: reorganize files
This commit is contained in:
39
src/apis/request/biz/composed/detail-device.ts
Normal file
39
src/apis/request/biz/composed/detail-device.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import { detailCameraApi, detailDevoderApi, detailKeyboardAPi, detailMediaServerApi, detailNvr, detailSecurityBoxApi, detailSwitchApi, detailVideoServerApi, type NdmDeviceResultVO } from '@/apis';
|
||||
import { DeviceType, tryGetDeviceTypeVal } from '@/enums';
|
||||
|
||||
export const detailDeviceApi = async (device: NdmDeviceResultVO, options?: { stationCode?: string; signal?: AbortSignal }): Promise<NdmDeviceResultVO | undefined> => {
|
||||
const { stationCode, signal } = options ?? {};
|
||||
const { id, deviceType: deviceTypeCode } = device;
|
||||
if (!id || !deviceTypeCode) {
|
||||
throw new Error('未知的设备');
|
||||
}
|
||||
const deviceTypeVal = tryGetDeviceTypeVal(deviceTypeCode);
|
||||
if (!deviceTypeVal) {
|
||||
throw new Error('未知的设备类型');
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.Camera) {
|
||||
return await detailCameraApi(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.Decoder) {
|
||||
return await detailDevoderApi(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.Keyboard) {
|
||||
return await detailKeyboardAPi(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.MediaServer) {
|
||||
return await detailMediaServerApi(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.Nvr) {
|
||||
return await detailNvr(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.SecurityBox) {
|
||||
return await detailSecurityBoxApi(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.Switch) {
|
||||
return await detailSwitchApi(id, { stationCode, signal });
|
||||
}
|
||||
if (deviceTypeVal === DeviceType.VideoServer) {
|
||||
return await detailVideoServerApi(id, { stationCode, signal });
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
Reference in New Issue
Block a user