48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import http from '@core/http';
|
|
|
|
const enum API {
|
|
根据设备类型查询 = '/device/mapping/queryByType',
|
|
}
|
|
|
|
/**
|
|
* 设备映射数据传输对象
|
|
*/
|
|
export interface DeviceMappingDTO {
|
|
id: string;
|
|
deviceUniqueName: string;
|
|
protocolType: string;
|
|
mappingType: string;
|
|
brandName: string | null;
|
|
ipAddress: string | null;
|
|
port: number;
|
|
slaveId: number;
|
|
enabled: number;
|
|
sceneId: string | null;
|
|
}
|
|
|
|
/**
|
|
* 设备类型映射
|
|
*/
|
|
export const DeviceTypeMapping = {
|
|
'0': '非保持呼叫器',
|
|
'4': '保持呼叫器',
|
|
'1': '门',
|
|
'2': '电梯',
|
|
'3': '光电传感器'
|
|
} as const;
|
|
|
|
/**
|
|
* 根据设备类型查询所有映射关系
|
|
* @param type 设备类型(必填)
|
|
* @returns DeviceMappingDTO[] 设备映射列表
|
|
*/
|
|
export async function queryDeviceMappingByType(type: string): Promise<DeviceMappingDTO[]> {
|
|
type ResponseType = DeviceMappingDTO[];
|
|
try {
|
|
const response = await http.get<ResponseType>(`${API.根据设备类型查询}?type=${type}`);
|
|
return response || [];
|
|
} catch (error) {
|
|
console.error('根据设备类型查询映射关系失败:', error);
|
|
return [];
|
|
}
|
|
} |