nayota-show-sdk 0.0.5 → 0.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/api/product.js +211 -61
- package/package.json +1 -1
package/api/product.js
CHANGED
|
@@ -5,66 +5,126 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { requestShow as request } from '../utils'
|
|
7
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
|
-
|
|
8
|
+
|
|
9
|
+
// * RS485设备创建所需参数
|
|
10
|
+
// * {
|
|
11
|
+
// * name: '485设备',
|
|
12
|
+
// * shortAddress: '06',
|
|
13
|
+
// * depart: '667d2ecc52d21700095b58b4',
|
|
14
|
+
// * control: '667a30ea3d569977280ea5fc',
|
|
15
|
+
// * parentType: 1,
|
|
16
|
+
// * parentId: '667a30ea3d569977280ea5fc',
|
|
17
|
+
// * }
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* RS485父级设备类型枚举
|
|
21
|
+
* @readonly
|
|
22
|
+
* @enum {number}
|
|
23
|
+
*/
|
|
24
|
+
var parentType = {
|
|
25
|
+
TCP: 1,
|
|
26
|
+
MQTT: 2
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Lorawan设备类型枚举
|
|
31
|
+
* @readonly
|
|
32
|
+
* @enum {number}
|
|
33
|
+
*/
|
|
34
|
+
var lorawanType = {
|
|
35
|
+
OTTA: 0,
|
|
36
|
+
ABP: 1
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* TCP设备类型枚举
|
|
41
|
+
* @readonly
|
|
42
|
+
* @enum {number}
|
|
43
|
+
*/
|
|
44
|
+
var tcpType = {
|
|
45
|
+
tcp客户端: 0,
|
|
46
|
+
tcp服务端: 1,
|
|
47
|
+
udp客户端: 2,
|
|
48
|
+
udp服务端: 3
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* @typedef {Object} Hardware设备创建所需参数
|
|
52
|
+
* @property {string} _id - 产品id
|
|
53
|
+
* @property {string} name - 设备名称
|
|
54
|
+
* @property {string} shortAddress - 短地址
|
|
55
|
+
* @property {string} depart - 可视化层级的id
|
|
56
|
+
* @property {string} control - 网关id
|
|
57
|
+
* @property {number} parentType - 查看枚举类型parentType{@link parentType}。
|
|
58
|
+
* @property {string} parentId - 所属父级设备的id。
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* @typedef {Object} Lorawan设备创建所需参数
|
|
63
|
+
* @property {string} _id - 产品id
|
|
64
|
+
* @property {string} name - 设备名称
|
|
65
|
+
* @property {string} shortAddress - 短地址
|
|
66
|
+
* @property {string} depart - 可视化层级的id
|
|
67
|
+
* @property {string} control - 网关id
|
|
68
|
+
* @property {number} type - 查看枚举类型lorawanType{@link lorawanType}。
|
|
69
|
+
* @property {string} devEui - devEui。
|
|
70
|
+
* @property {string} deviceProfileId - deviceProfileId。
|
|
71
|
+
* @property {string} deviceKeys - deviceKeys当type字段为0时必选。
|
|
72
|
+
* @property {string} devAddr - devAddr当type字段为1时必选。
|
|
73
|
+
* @property {string} nwkSkey - nwkSkey当type字段为1时必选。
|
|
74
|
+
* @property {string} appSkey - appSkey当type字段为1时必选。
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* @typedef {Object} TCP设备创建所需参数
|
|
80
|
+
* @property {string} _id - 产品id
|
|
81
|
+
* @property {string} name - 设备名称
|
|
82
|
+
* @property {string} shortAddress - 短地址
|
|
83
|
+
* @property {string} depart - 可视化层级的id
|
|
84
|
+
* @property {string} control - 网关id
|
|
85
|
+
* @property {number} type - 查看枚举类型tcpType。
|
|
86
|
+
* @property {number} range - 设备轮询时间ms单位,默认为3000ms。
|
|
87
|
+
* @property {string} tcp_client_ip - tcpIp,type为0或者1时必选。
|
|
88
|
+
* @property {string} tcp_client_port - tcp端口,type为1时必选。
|
|
89
|
+
* @property {string} udp_client_ip - udpIp,type为2或者3时必选。
|
|
90
|
+
* @property {string} udp_client_port - udp端口,type为3时必选。
|
|
91
|
+
*/
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {Object} HttpDrive设备创建所需参数
|
|
95
|
+
* @property {string} _id - 产品id
|
|
96
|
+
* @property {string} name - 设备名称
|
|
97
|
+
* @property {string} shortAddress - 短地址
|
|
98
|
+
* @property {string} depart - 可视化层级的id
|
|
99
|
+
* @property {string} control - 网关id
|
|
100
|
+
* @property {string} ip - 设备IP地址。
|
|
101
|
+
* @property {string} port - 设备端口默认80。
|
|
102
|
+
* @property {string} url - 设备url。
|
|
103
|
+
* @property {number} range - 设备轮询时间ms单位,默认为3000ms。
|
|
104
|
+
*/
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @typedef {Object} 摄像头设备创建所需参数
|
|
108
|
+
* @property {string} _id - 产品id
|
|
109
|
+
* @property {string} name - 设备名称
|
|
110
|
+
* @property {string} depart - 可视化层级的id
|
|
111
|
+
* @property {string} thirdPartyCameraAccount - 平台账号id,查config三方摄像头账号接口,平台摄像头必选。
|
|
112
|
+
* @property {number} number - 设备序号,平台摄像头必选。
|
|
113
|
+
* @property {number} channelNo - 通道号,平台摄像头且三方摄像头的类型为2时必选,其余三方摄像头类型可选。
|
|
114
|
+
* @property {string} iconName - 设备图标。
|
|
115
|
+
* @property {string} local_ip - 本地RTSP地址,本地摄像头必选。
|
|
116
|
+
* @property {string} local_username - 本地用户名,本地摄像头必选。
|
|
117
|
+
* @property {string} local_password - 本地密码,本地摄像头必选。
|
|
118
|
+
* @property {string} describe - 设备备注。
|
|
119
|
+
* @property {boolean} line - 设备在离线。
|
|
120
|
+
* @property {boolean} hasPtz - 是否带云台。
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* 通过产品类型添加设备,该接口会同时创建IOT设备、展示设备及可视化设备。
|
|
127
|
+
* @param {Object} data - 包含参数的请求体,data对象通过判断产品类型中的IOT设备类型字段创建不同类型的设备,摄像头设备则通过判断产品标签去判断,以下为不同类型设备创建所需参数。
|
|
68
128
|
* @example <caption>请求范例</caption>
|
|
69
129
|
* RS485设备创建所需参数
|
|
70
130
|
* {
|
|
@@ -156,6 +216,7 @@ import { requestShow as request } from '../utils'
|
|
|
156
216
|
* }
|
|
157
217
|
* 摄像头设备创建所需参数
|
|
158
218
|
* 平台摄像头所传参数
|
|
219
|
+
* 1. 当三方摄像头账号type为2时,number和channelNo必选,其余type类型number必选channelNo可选
|
|
159
220
|
* {
|
|
160
221
|
* name: '摄像头设备',
|
|
161
222
|
* depart: '667d2ecc52d21700095b58b4',
|
|
@@ -204,6 +265,95 @@ function createAllDevice(data) {
|
|
|
204
265
|
})
|
|
205
266
|
}
|
|
206
267
|
|
|
268
|
+
/**
|
|
269
|
+
* 查询产品列表
|
|
270
|
+
* @param {Object} query - 查询条件
|
|
271
|
+
* @param {string} query.name - 设备名称。
|
|
272
|
+
*
|
|
273
|
+
*/
|
|
274
|
+
function list(query) {
|
|
275
|
+
return request({
|
|
276
|
+
url: '/products',
|
|
277
|
+
method: 'get',
|
|
278
|
+
params: query
|
|
279
|
+
})
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* 创建产品信息
|
|
284
|
+
* @param {Object} data - 创建产品信息
|
|
285
|
+
* @param {string} data.name - 产品名称。
|
|
286
|
+
* @param {string} data.productCode - 产品型号。
|
|
287
|
+
* @param {string} data.tags - 产品标签
|
|
288
|
+
* @param {string} data.brand - 产品品牌
|
|
289
|
+
* @param {string} data.img - 产品图片
|
|
290
|
+
* @param {string} data.info - 产品详情
|
|
291
|
+
* @param {string} data.access - 接入方式
|
|
292
|
+
* @param {string} data.supplyModel - 供电方式
|
|
293
|
+
* @param {string} data.protocolType - 通信协议
|
|
294
|
+
* @param {string} data.description - 产品描述
|
|
295
|
+
* @param {string} data.hardwareWord - 设备字典
|
|
296
|
+
* @param {string} data.addressDesc - 地址介绍
|
|
297
|
+
* @param {string} data.deviceUI - 展示模型UIid。
|
|
298
|
+
* @param {string} data.deviceType - IOT设备类型
|
|
299
|
+
*/
|
|
300
|
+
function create(data) {
|
|
301
|
+
return request({
|
|
302
|
+
url: '/products',
|
|
303
|
+
method: 'post',
|
|
304
|
+
data
|
|
305
|
+
})
|
|
306
|
+
}
|
|
307
|
+
/**
|
|
308
|
+
* 查询单个产品
|
|
309
|
+
* @param {Object} id - 产品id
|
|
310
|
+
*/
|
|
311
|
+
function getOne(id) {
|
|
312
|
+
return request({
|
|
313
|
+
url: '/products/' + id,
|
|
314
|
+
method: 'get'
|
|
315
|
+
})
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* 更新单个产品
|
|
319
|
+
* @param {Object} data
|
|
320
|
+
* @param {string} data._id - 产品id
|
|
321
|
+
* @param {string} data.name - 产品名称
|
|
322
|
+
*/
|
|
323
|
+
function updateOne(data) {
|
|
324
|
+
return request({
|
|
325
|
+
url: `/products/${data._id}`,
|
|
326
|
+
method: 'put',
|
|
327
|
+
data
|
|
328
|
+
})
|
|
329
|
+
}
|
|
330
|
+
/**
|
|
331
|
+
* 删除单个产品
|
|
332
|
+
* @param {Object} id - 产品id
|
|
333
|
+
*/
|
|
334
|
+
function deleteOne(id) {
|
|
335
|
+
return request({
|
|
336
|
+
url: `/products/${id}`,
|
|
337
|
+
method: 'delete'
|
|
338
|
+
})
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* 批量删除产品
|
|
342
|
+
* @param {Object} ids - 产品id数组
|
|
343
|
+
*/
|
|
344
|
+
function deleteMany(ids) {
|
|
345
|
+
return request({
|
|
346
|
+
url: '/products',
|
|
347
|
+
method: 'delete',
|
|
348
|
+
data: ids // delete传递主体要包含在data里
|
|
349
|
+
})
|
|
350
|
+
}
|
|
207
351
|
export default {
|
|
208
|
-
createAllDevice
|
|
352
|
+
createAllDevice,
|
|
353
|
+
create,
|
|
354
|
+
list,
|
|
355
|
+
getOne,
|
|
356
|
+
updateOne,
|
|
357
|
+
deleteOne,
|
|
358
|
+
deleteMany
|
|
209
359
|
}
|