nayota-show-sdk 0.1.0 → 0.1.2

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.
@@ -0,0 +1,151 @@
1
+ import { requestShow } from '../utils'
2
+ /**
3
+ * @file 设备类型api
4
+ * @module 设备类型接口
5
+ */
6
+
7
+
8
+ /**
9
+ * 属性数据维度dataDimension
10
+ * @readonly
11
+ * @enum {string}
12
+ */
13
+ var dataDimension = {
14
+ 日: 'day',
15
+ 月: 'month',
16
+ 年: 'year'
17
+ }
18
+
19
+ /**
20
+ * 属性类型propType
21
+ * @readonly
22
+ * @enum {string}
23
+ */
24
+ var propType = {
25
+ check: 'check',
26
+ operate: 'operate'
27
+ }
28
+
29
+
30
+ /**
31
+ * UI模型类型uiType
32
+ * @readonly
33
+ * @enum {string}
34
+ */
35
+ var uiType = {
36
+ 画布: 'canvas',
37
+ 组件: 'component'
38
+ }
39
+
40
+ /**
41
+ * @typedef {Object} deviceClass设备类型
42
+ * @property {string} _id - 设备类型id
43
+ * @property {string} name - 设备类型名称.
44
+ * @property {string} icon - 设备类型图标
45
+ * @property {string} code - 设备类型编码
46
+ * @property {string} departTag - 设备类型的层级标签
47
+ * @property {Array} attribute - 设备类型属性
48
+ * @property {string} props._id - 属性id
49
+ * @property {string} props.name - 属性名称
50
+ * @property {string} props.key - 属性key
51
+ * @property {string} props.dataDimension - 属性数据维度,默认为day天,查看枚举dataDimension
52
+ * @property {string} props.type - 属性类型,查看枚举propType
53
+ * @property {boolean} props.filterable - 属性是否可搜索
54
+ * @property {boolean} props.lineType - 属性在离线判定是否开启
55
+ * @property {string} props.lineTime - 属性在离线判定时间(单位小时)
56
+ * @property {boolean} props.statusType - 属性是否开启异常值判定
57
+ * @property {string} props.interval - 属性异常值判定的区间
58
+ * @property {array} relations - 与IOT字典的绑定关系
59
+ * @property {string} relations.hwId - 字典id
60
+ * @property {string} relations.hwName - 字典名称
61
+ * @property {string} relations.hwType - 字典类型
62
+ * @property {string} relations.hwCode - 字典编码
63
+ * @property {array} relations.attrs - 设备属性和字典的绑定关系
64
+ * @property {array} uis - 与UI模型的关系
65
+ * @property {string} uis.uiId - UI模型id
66
+ * @property {string} uis.uiName - UI模型名称
67
+ * @property {string} uis.uiCode - UI模型编码
68
+ * @property {string} uis.type - UI模型类型查看枚举uiType
69
+ * @property {array} uis.attrs - 设备属性和UI模型的绑定关系
70
+ * @property {string} deviceUI - 设备类型关联IOT展示模型的_id
71
+ * @property {boolean} isSimulation - 设备类型是否为模拟
72
+ */
73
+
74
+ /**
75
+ *
76
+ * @param {*} query
77
+ * @param {number} query.page - 页码
78
+ * @param {number} query.limit - 每页数量
79
+ * @returns {number} code - 返回码,0表示成功
80
+ * @returns {number} total - 设备总数
81
+ * @returns {Array} rows - 设备数组查看设备数据定义
82
+ */
83
+ export function list(query) {
84
+ return request({
85
+ url: '/device-classes',
86
+ method: 'get',
87
+ params: query
88
+ })
89
+ }
90
+
91
+ /**
92
+ * 新增设备
93
+ * @param {Object} data - 包含设备的请求体 属性见list返回字段。
94
+ * @returns {number} code - 返回码,0表示成功
95
+ * @returns {string} data - 新增成功的数据 跟list返回字段一致
96
+ */
97
+ export function create(data) {
98
+ return requestShow({
99
+ url: '/device-classes',
100
+ method: 'post',
101
+ data
102
+ })
103
+ }
104
+
105
+ /**
106
+ * 修改设备
107
+ * @param {Object} data - 包含设备的请求体 属性见list返回字段。
108
+ * @returns {number} code - 返回码,0表示成功
109
+ * @returns {string} data - 修改成功的数据 跟list返回字段一致
110
+ */
111
+ export function updateOne(data) {
112
+ return requestShow({
113
+ url: `/device-classes/${data._id}`,
114
+ method: 'put',
115
+ data
116
+ })
117
+ }
118
+ /**
119
+ * 删除设备
120
+ * @param {string} id - 删除的设备id。
121
+ * @returns {number} code - 返回码,0表示成功
122
+ * @returns {string} data - 删除成功的数据 跟list返回字段一致
123
+ */
124
+ export function deleteOne(id) {
125
+ return requestShow({
126
+ url: `/device-classes/${id}`,
127
+ method: 'delete'
128
+ })
129
+ }
130
+
131
+ /**
132
+ * 批量删除设备
133
+ * @param {Array} ids - 删除的设备ids。
134
+ * @returns {number} code - 返回码,0表示成功
135
+ */
136
+ export function deleteMany(ids) {
137
+ return requestShow({
138
+ url: '/device-classes',
139
+ method: 'delete',
140
+ data: ids // delete传递主体要包含在data里
141
+ })
142
+ }
143
+
144
+ export default {
145
+ list,
146
+ create,
147
+ updateOne,
148
+ deleteOne,
149
+ deleteMany
150
+ }
151
+
package/api/devices.js CHANGED
@@ -39,10 +39,10 @@ var deviceStatus = {
39
39
  }
40
40
 
41
41
  /**
42
- * @typedef {Object} device
42
+ * @typedef {Object} device设备
43
43
  * @property {string} _id - 设备id
44
44
  * @property {string} name - 设备名称.
45
- * @property {Array} hash - 根据参数PropId生成,用于判定设备是否已经导入(新版弃用)
45
+ * @property {Array} hash - 根据参数PropId生成,用于判定设备是否已经导入
46
46
  * @property {Array} latLng - 设备在平面图上的经纬度
47
47
  * @property {Array} mapLatLng - 设备在地图上的经纬度
48
48
  * @property {string} shortAddress - 设备短地址
package/index.js CHANGED
@@ -8,6 +8,8 @@ import router from './api/router'
8
8
  import departs from './api/departs'
9
9
  import bmsRole from './api/bmsRole'
10
10
  import bmsRouter from './api/bmsRouter'
11
+ import devices from './api/devices'
12
+ import deviceClass from './api/deviceClass'
11
13
  const api = {
12
14
  alarmRecord,
13
15
  alarmProgress,
@@ -15,7 +17,9 @@ const api = {
15
17
  router,
16
18
  departs,
17
19
  bmsRole,
18
- bmsRouter
20
+ bmsRouter,
21
+ devices,
22
+ deviceClass
19
23
  }
20
24
 
21
25
  export default { config: options => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nayota-show-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "nayota-show-server rest-api",
5
5
  "type": "module",
6
6
  "main": "index.js",