nayota-show-sdk 0.0.8 → 0.1.0
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/bmsRole.js +107 -0
- package/api/bmsRouter.js +119 -0
- package/api/devices.js +156 -0
- package/api/router.js +1 -1
- package/index.js +5 -1
- package/package.json +1 -1
package/api/bmsRole.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { requestShow } from '../utils'
|
|
2
|
+
/**
|
|
3
|
+
* @file BMS角色api
|
|
4
|
+
* @module BMS角色接口
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 角色类型枚举
|
|
10
|
+
* @readonly
|
|
11
|
+
* @enum {number}
|
|
12
|
+
*/
|
|
13
|
+
var userType = {
|
|
14
|
+
主角色: 0,
|
|
15
|
+
副角色: 1
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
*
|
|
19
|
+
* @param {*} query
|
|
20
|
+
* @param {number} query.page - 页码
|
|
21
|
+
* @param {number} query.limit - 每页数量
|
|
22
|
+
* @returns {number} code - 返回码,0表示成功
|
|
23
|
+
* @returns {number} total - 角色总数
|
|
24
|
+
* @returns {Array} rows - 角色数组
|
|
25
|
+
* @returns {string} rows._id - 角色id
|
|
26
|
+
* @returns {string} rows.name - 角色名称必须唯一
|
|
27
|
+
* @returns {number} rows.sort - 排序序号
|
|
28
|
+
* @returns {string} rows.desc - 角色描述
|
|
29
|
+
* @returns {Object} rows.users - 关联的用户列表
|
|
30
|
+
* @returns {number} rows.type - 角色通用类型默认为-0
|
|
31
|
+
* @returns {number} rows.userType - 查看枚举userType
|
|
32
|
+
* @returns {Array} rows.userIds - 关联的用户id列表
|
|
33
|
+
* @returns {boolean} rows.control - 是否可控制默认为true
|
|
34
|
+
* @returns {Array} rows.routers - 拥有的权限列表
|
|
35
|
+
* @returns {string} rows.routers.subject - 权限主题
|
|
36
|
+
* @returns {Array} rows.routers.actions - 权限列表
|
|
37
|
+
* @returns {Array} rows.routers.children - 路由列表
|
|
38
|
+
*/
|
|
39
|
+
export function list(query) {
|
|
40
|
+
return requestShow({
|
|
41
|
+
url: '/bms-roles',
|
|
42
|
+
method: 'get',
|
|
43
|
+
params: query
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* 新增路由
|
|
49
|
+
* @param {Object} data - 包含路由的请求体 属性见list返回字段。
|
|
50
|
+
* @returns {number} code - 返回码,0表示成功
|
|
51
|
+
* @returns {string} data - 新增成功的数据 跟list返回字段一致
|
|
52
|
+
*/
|
|
53
|
+
export function create(data) {
|
|
54
|
+
return requestShow({
|
|
55
|
+
url: '/bms-roles',
|
|
56
|
+
method: 'post',
|
|
57
|
+
data
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 修改路由
|
|
63
|
+
* @param {Object} data - 包含路由的请求体 属性见list返回字段。
|
|
64
|
+
* @returns {number} code - 返回码,0表示成功
|
|
65
|
+
* @returns {string} data - 修改成功的数据 跟list返回字段一致
|
|
66
|
+
*/
|
|
67
|
+
export function updateOne(data) {
|
|
68
|
+
return requestShow({
|
|
69
|
+
url: `/bms-roles/${data._id}`,
|
|
70
|
+
method: 'put',
|
|
71
|
+
data
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* 删除路由
|
|
76
|
+
* @param {string} id - 删除的路由id。
|
|
77
|
+
* @returns {number} code - 返回码,0表示成功
|
|
78
|
+
* @returns {string} data - 删除成功的数据 跟list返回字段一致
|
|
79
|
+
*/
|
|
80
|
+
export function deleteOne(id) {
|
|
81
|
+
return requestShow({
|
|
82
|
+
url: `/bms-roles/${id}`,
|
|
83
|
+
method: 'delete'
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* 批量删除路由
|
|
89
|
+
* @param {Array} ids - 删除的路由ids。
|
|
90
|
+
* @returns {number} code - 返回码,0表示成功
|
|
91
|
+
*/
|
|
92
|
+
export function deleteMany(ids) {
|
|
93
|
+
return requestShow({
|
|
94
|
+
url: '/bms-roles',
|
|
95
|
+
method: 'delete',
|
|
96
|
+
data: ids // delete传递主体要包含在data里
|
|
97
|
+
})
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export default {
|
|
101
|
+
list,
|
|
102
|
+
create,
|
|
103
|
+
updateOne,
|
|
104
|
+
deleteOne,
|
|
105
|
+
deleteMany
|
|
106
|
+
}
|
|
107
|
+
|
package/api/bmsRouter.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { requestShow } from '../utils'
|
|
2
|
+
/**
|
|
3
|
+
* @file BMS路由api
|
|
4
|
+
* @module BMS路由接口
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 路由method枚举
|
|
10
|
+
* @readonly
|
|
11
|
+
* @enum {string}
|
|
12
|
+
*/
|
|
13
|
+
var method = {
|
|
14
|
+
all: 'all',
|
|
15
|
+
get: 'get',
|
|
16
|
+
post: 'post',
|
|
17
|
+
put: 'put',
|
|
18
|
+
delete: 'delete'
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
*
|
|
22
|
+
* @param {*} query
|
|
23
|
+
* @param {number} query.page - 页码
|
|
24
|
+
* @param {number} query.limit - 每页数量
|
|
25
|
+
* @returns {number} code - 返回码,0表示成功
|
|
26
|
+
* @returns {number} total - 路由总数
|
|
27
|
+
* @returns {Array} rows - 路由数组
|
|
28
|
+
* @returns {string} rows._id - 路由id
|
|
29
|
+
* @returns {string} rows.type - 路由类型
|
|
30
|
+
* @returns {string} rows.name - 路由名称
|
|
31
|
+
* @returns {string} rows.path - 路由路径
|
|
32
|
+
* @returns {number} rows.level - 路由等级
|
|
33
|
+
* @returns {number} rows.sort - 排序序号
|
|
34
|
+
* @returns {Array} rows.children - 子路由列表
|
|
35
|
+
* @returns {string} rows.method - 查看枚举method
|
|
36
|
+
* @returns {string} rows.desc - 路由描述
|
|
37
|
+
* @returns {Array} rows.roles - 关联的角色列表
|
|
38
|
+
* @returns {Array} rows.actions - 关联的功能列表
|
|
39
|
+
* @returns {string} rows.actions.name - 功能名称
|
|
40
|
+
* @returns {string} rows.actions.code - 功能编码
|
|
41
|
+
* @returns {string} rows.subject - 主题
|
|
42
|
+
* @returns {Array} rows.deviceClass - 关联的设备类型
|
|
43
|
+
* @returns {string} rows.deviceClass.name - 设备类型名称
|
|
44
|
+
* @returns {string} rows.deviceClass.icon - 设备类型图标
|
|
45
|
+
* @returns {string} rows.deviceClass.code - 设备类型编码
|
|
46
|
+
* @returns {string} rows.deviceClass.departTag - 设备类型层级标签
|
|
47
|
+
* @returns {Object} rows.deviceClass.uis - 设备类型ui信息
|
|
48
|
+
* @returns {string} rows.customJson - 自定义json
|
|
49
|
+
* @returns {string} rows.icon - 图标
|
|
50
|
+
*/
|
|
51
|
+
export function list(query) {
|
|
52
|
+
return requestShow({
|
|
53
|
+
url: '/bms-routers',
|
|
54
|
+
method: 'get',
|
|
55
|
+
params: query
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 新增路由
|
|
61
|
+
* @param {Object} data - 包含路由的请求体 属性见list返回字段。
|
|
62
|
+
* @returns {number} code - 返回码,0表示成功
|
|
63
|
+
* @returns {string} data - 新增成功的数据 跟list返回字段一致
|
|
64
|
+
*/
|
|
65
|
+
export function create(data) {
|
|
66
|
+
return requestShow({
|
|
67
|
+
url: '/bms-routers',
|
|
68
|
+
method: 'post',
|
|
69
|
+
data
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 修改路由
|
|
75
|
+
* @param {Object} data - 包含路由的请求体 属性见list返回字段。
|
|
76
|
+
* @returns {number} code - 返回码,0表示成功
|
|
77
|
+
* @returns {string} data - 修改成功的数据 跟list返回字段一致
|
|
78
|
+
*/
|
|
79
|
+
export function updateOne(data) {
|
|
80
|
+
return requestShow({
|
|
81
|
+
url: `/bms-routers/${data._id}`,
|
|
82
|
+
method: 'put',
|
|
83
|
+
data
|
|
84
|
+
})
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* 删除路由
|
|
88
|
+
* @param {string} id - 删除的路由id。
|
|
89
|
+
* @returns {number} code - 返回码,0表示成功
|
|
90
|
+
* @returns {string} data - 删除成功的数据 跟list返回字段一致
|
|
91
|
+
*/
|
|
92
|
+
export function deleteOne(id) {
|
|
93
|
+
return requestShow({
|
|
94
|
+
url: `/bms-routers/${id}`,
|
|
95
|
+
method: 'delete'
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* 批量删除路由
|
|
101
|
+
* @param {Array} ids - 删除的路由ids。
|
|
102
|
+
* @returns {number} code - 返回码,0表示成功
|
|
103
|
+
*/
|
|
104
|
+
export function deleteMany(ids) {
|
|
105
|
+
return requestShow({
|
|
106
|
+
url: '/bms-routers',
|
|
107
|
+
method: 'delete',
|
|
108
|
+
data: ids // delete传递主体要包含在data里
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default {
|
|
113
|
+
list,
|
|
114
|
+
create,
|
|
115
|
+
updateOne,
|
|
116
|
+
deleteOne,
|
|
117
|
+
deleteMany
|
|
118
|
+
}
|
|
119
|
+
|
package/api/devices.js
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
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: 'day',
|
|
15
|
+
year: 'year'
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 节点类型propType
|
|
20
|
+
* @readonly
|
|
21
|
+
* @enum {string}
|
|
22
|
+
*/
|
|
23
|
+
var propType = {
|
|
24
|
+
check: 'check',
|
|
25
|
+
operate: 'operate'
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* 设备状态deviceStatus
|
|
30
|
+
* @readonly
|
|
31
|
+
* @enum {number}
|
|
32
|
+
*/
|
|
33
|
+
var deviceStatus = {
|
|
34
|
+
正常: 0,
|
|
35
|
+
告警: 1,
|
|
36
|
+
异常: 2,
|
|
37
|
+
故障: 3,
|
|
38
|
+
离线: 4
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @typedef {Object} device
|
|
43
|
+
* @property {string} _id - 设备id
|
|
44
|
+
* @property {string} name - 设备名称.
|
|
45
|
+
* @property {Array} hash - 根据参数PropId生成,用于判定设备是否已经导入(新版弃用)
|
|
46
|
+
* @property {Array} latLng - 设备在平面图上的经纬度
|
|
47
|
+
* @property {Array} mapLatLng - 设备在地图上的经纬度
|
|
48
|
+
* @property {string} shortAddress - 设备短地址
|
|
49
|
+
* @property {Array} attribute - 设备属性
|
|
50
|
+
* @property {string} attribute.key - 设备属性key
|
|
51
|
+
* @property {string} attribute.value - 设备属性value
|
|
52
|
+
* @property {string} attribute.note - 设备属性备注
|
|
53
|
+
* @property {Array} props - 设备节点
|
|
54
|
+
* @property {string} props._id - 节点id
|
|
55
|
+
* @property {string} props.name - 节点名称
|
|
56
|
+
* @property {string} props.key - 节点key
|
|
57
|
+
* @property {string} props.dataDimension - 节点数据维度,默认为day天,查看枚举dataDimension
|
|
58
|
+
* @property {string} props.type - 节点类型,查看枚举propType
|
|
59
|
+
* @property {string} props.propId - 节点propId,同IOT的check或者operate的_id
|
|
60
|
+
* @property {number} props.value - 节点最后值
|
|
61
|
+
* @property {string} props.valueStr - 节点最后值字符串
|
|
62
|
+
* @property {boolean} props.lineType - 节点在离线判定是否开启
|
|
63
|
+
* @property {string} props.lineTime - 节点在离线判定时间(单位小时)
|
|
64
|
+
* @property {boolean} props.statusType - 节点是否开启异常值判定
|
|
65
|
+
* @property {string} props.interval - 节点异常值判定的区间
|
|
66
|
+
* @property {string} props.company - 节点单位
|
|
67
|
+
* @property {array} props.enum - 节点枚举同IOT的区间
|
|
68
|
+
* @property {string} props.enum.label - 枚举字符串值
|
|
69
|
+
* @property {number} props.enum.value - 枚举值
|
|
70
|
+
* @property {number} props.enum.min - 枚举最小值
|
|
71
|
+
* @property {number} props.enum.max - 枚举最大值
|
|
72
|
+
* @property {string} n_device - 设备关联IOT展示设备的_id
|
|
73
|
+
* @property {string} depart - 设备层级id
|
|
74
|
+
* @property {number} order - 设备排序
|
|
75
|
+
* @property {string} deviceClass - 设备所属的设备类型
|
|
76
|
+
* @property {string} deviceStatus - 设备状态查看枚举deviceStatus
|
|
77
|
+
*/
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
*
|
|
81
|
+
* @param {*} query
|
|
82
|
+
* @param {number} query.page - 页码
|
|
83
|
+
* @param {number} query.limit - 每页数量
|
|
84
|
+
* @returns {number} code - 返回码,0表示成功
|
|
85
|
+
* @returns {number} total - 设备总数
|
|
86
|
+
* @returns {Array} rows - 设备数组查看设备数据定义
|
|
87
|
+
*/
|
|
88
|
+
export function list(query) {
|
|
89
|
+
return request({
|
|
90
|
+
url: '/devices',
|
|
91
|
+
method: 'get',
|
|
92
|
+
params: query
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 新增设备
|
|
98
|
+
* @param {Object} data - 包含设备的请求体 属性见list返回字段。
|
|
99
|
+
* @returns {number} code - 返回码,0表示成功
|
|
100
|
+
* @returns {string} data - 新增成功的数据 跟list返回字段一致
|
|
101
|
+
*/
|
|
102
|
+
export function create(data) {
|
|
103
|
+
return requestShow({
|
|
104
|
+
url: '/devices',
|
|
105
|
+
method: 'post',
|
|
106
|
+
data
|
|
107
|
+
})
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* 修改设备
|
|
112
|
+
* @param {Object} data - 包含设备的请求体 属性见list返回字段。
|
|
113
|
+
* @returns {number} code - 返回码,0表示成功
|
|
114
|
+
* @returns {string} data - 修改成功的数据 跟list返回字段一致
|
|
115
|
+
*/
|
|
116
|
+
export function updateOne(data) {
|
|
117
|
+
return requestShow({
|
|
118
|
+
url: `/devices/${data._id}`,
|
|
119
|
+
method: 'put',
|
|
120
|
+
data
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* 删除设备
|
|
125
|
+
* @param {string} id - 删除的设备id。
|
|
126
|
+
* @returns {number} code - 返回码,0表示成功
|
|
127
|
+
* @returns {string} data - 删除成功的数据 跟list返回字段一致
|
|
128
|
+
*/
|
|
129
|
+
export function deleteOne(id) {
|
|
130
|
+
return requestShow({
|
|
131
|
+
url: `/devices/${id}`,
|
|
132
|
+
method: 'delete'
|
|
133
|
+
})
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* 批量删除设备
|
|
138
|
+
* @param {Array} ids - 删除的设备ids。
|
|
139
|
+
* @returns {number} code - 返回码,0表示成功
|
|
140
|
+
*/
|
|
141
|
+
export function deleteMany(ids) {
|
|
142
|
+
return requestShow({
|
|
143
|
+
url: '/devices',
|
|
144
|
+
method: 'delete',
|
|
145
|
+
data: ids // delete传递主体要包含在data里
|
|
146
|
+
})
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default {
|
|
150
|
+
list,
|
|
151
|
+
create,
|
|
152
|
+
updateOne,
|
|
153
|
+
deleteOne,
|
|
154
|
+
deleteMany
|
|
155
|
+
}
|
|
156
|
+
|
package/api/router.js
CHANGED
|
@@ -3,6 +3,7 @@ import { requestShow } from '../utils'
|
|
|
3
3
|
* @file 路由api
|
|
4
4
|
* @module 路由接口
|
|
5
5
|
*/
|
|
6
|
+
|
|
6
7
|
/**
|
|
7
8
|
*
|
|
8
9
|
* @param {*} query
|
|
@@ -20,7 +21,6 @@ import { requestShow } from '../utils'
|
|
|
20
21
|
* @returns {('all'|'get'|'post'|'put'|'delete')} rows.method - HTTP请求方法
|
|
21
22
|
* @returns {string} rows.desc - 路由描述
|
|
22
23
|
* @returns {Array<mongoose.Schema.Types.ObjectId>} rows.roles - 关联的角色列表
|
|
23
|
-
* @returns {string} rows.icon - 路由图标
|
|
24
24
|
*/
|
|
25
25
|
export function list(query) {
|
|
26
26
|
return request({
|
package/index.js
CHANGED
|
@@ -6,12 +6,16 @@ import alarmProgress from './api/alarmProgress'
|
|
|
6
6
|
import systeminfo from './api/systeminfo'
|
|
7
7
|
import router from './api/router'
|
|
8
8
|
import departs from './api/departs'
|
|
9
|
+
import bmsRole from './api/bmsRole'
|
|
10
|
+
import bmsRouter from './api/bmsRouter'
|
|
9
11
|
const api = {
|
|
10
12
|
alarmRecord,
|
|
11
13
|
alarmProgress,
|
|
12
14
|
systeminfo,
|
|
13
15
|
router,
|
|
14
|
-
departs
|
|
16
|
+
departs,
|
|
17
|
+
bmsRole,
|
|
18
|
+
bmsRouter
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
export default { config: options => {
|