deviceManager.ts
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import { defHttp } from '/@/utils/http/axios';
import {
DeviceModel,
DeviceProfileModel,
DeviceProfileQueryParam,
DeviceQueryParam,
} from '/@/api/device/model/deviceModel';
enum DeviceManagerApi {
/**
* 设备URL
*/
DEVICE_URL = '/device',
/**
* 设备配置URL
*/
DEVICE_PROFILE_URL = '/deviceProfile',
DEVICE_PROFILE_URL_ME = '/deviceProfile/me/list',
DEVICE_ALARM_URL = '/alarm',
DEVICE_CREDENTIALS = '/device/credentials',
}
export const devicePage = (params: DeviceQueryParam) => {
return defHttp.get<DeviceModel>({
url: DeviceManagerApi.DEVICE_URL,
params,
});
};
/**
* 分页查询设备配置页面
* @param params pageSize page name
*/
export const deviceProfilePage = (params: DeviceProfileQueryParam) => {
return defHttp.get<DeviceProfileModel>({
url: DeviceManagerApi.DEVICE_PROFILE_URL,
params,
});
};
/**
* 删除设备配置
* @param ids 删除的ids
*/
export const deleteDeviceProfile = (ids: string[]) => {
return defHttp.delete({
url: DeviceManagerApi.DEVICE_PROFILE_URL,
data: {
ids: ids,
},
});
};
/**
* 删除设备
* @param ids 删除的ids
*/
export const deleteDevice = (ids: string[]) => {
return defHttp.delete({
url: DeviceManagerApi.DEVICE_URL,
data: {
ids: ids,
},
});
};
/**
* 查询设备配置
* @param params pageSize page name
*/
export const deviceProfile = () => {
return defHttp.get({
url: DeviceManagerApi.DEVICE_PROFILE_URL_ME,
});
};
// 创建或编辑设备
export const createOrEditDevice = (data) => {
return defHttp.post({
url: DeviceManagerApi.DEVICE_URL,
data,
});
};
// 查询设备详情
export const getDeviceDetail = (id: string) => {
return defHttp.get({
url: DeviceManagerApi.DEVICE_URL + `/${id}`,
});
};
// 查询设备详情中的告警
export const getDeviceAlarm = (params?: DeviceProfileQueryParam) => {
return defHttp.get({
url: DeviceManagerApi.DEVICE_ALARM_URL,
params,
});
};
// 如果是flag为true 就是清除报警,否则是处理报警
export const clearOrAckAlarm = (id: string, flag: boolean) => {
return defHttp.post(
{
url: `${DeviceManagerApi.DEVICE_ALARM_URL}/${id}/${flag ? 'clear' : 'ack'}`,
},
{
joinPrefix: false,
}
);
};
// 获取设备凭证详情
export const getDeviceToken = (id: string) => {
return defHttp.get(
{
url: `${DeviceManagerApi.DEVICE_URL}/${id}/credentials`,
},
{
joinPrefix: false,
}
);
};
// 保存设备凭证详情
export const saveDeviceToken = (data) => {
return defHttp.post(
{
url: DeviceManagerApi.DEVICE_CREDENTIALS,
data,
},
{
joinPrefix: false,
}
);
};