nayota-show-sdk 1.3.93 → 1.3.95
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/fireDrillRecords.js +91 -0
- package/api/fireDrillRecords.test.js +75 -0
- package/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { requestShow } from '../utils'
|
|
2
|
+
|
|
3
|
+
const baseUrl = '/fire-drill-records'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 获取消防演练回放记录列表
|
|
7
|
+
* @param {Object} query - 查询参数
|
|
8
|
+
* @param {number} [query.page] - 页码
|
|
9
|
+
* @param {number} [query.limit] - 每页数量
|
|
10
|
+
* @param {string} [query.name] - 演练名称,模糊查询
|
|
11
|
+
* @param {string} [query.status] - 演练状态
|
|
12
|
+
* @param {string} [query.hierarchyID] - 主体层级/区域 ID
|
|
13
|
+
* @param {string} [query.hierarchyPathId] - 层级路径中的任意 ID
|
|
14
|
+
* @param {number} [query.startTimeFrom] - 开始时间范围起点,毫秒时间戳
|
|
15
|
+
* @param {number} [query.startTimeTo] - 开始时间范围终点,毫秒时间戳
|
|
16
|
+
*/
|
|
17
|
+
export function list(query) {
|
|
18
|
+
return requestShow({
|
|
19
|
+
url: baseUrl,
|
|
20
|
+
method: 'get',
|
|
21
|
+
params: query
|
|
22
|
+
})
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* 新增消防演练回放记录
|
|
27
|
+
* @param {Object} data - 消防演练回放记录
|
|
28
|
+
*/
|
|
29
|
+
export function create(data) {
|
|
30
|
+
return requestShow({
|
|
31
|
+
url: baseUrl,
|
|
32
|
+
method: 'post',
|
|
33
|
+
data
|
|
34
|
+
})
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* 获取消防演练回放记录详情
|
|
39
|
+
* @param {string} id - 记录 ID
|
|
40
|
+
*/
|
|
41
|
+
export function getOne(id) {
|
|
42
|
+
return requestShow({
|
|
43
|
+
url: `${baseUrl}/${id}`,
|
|
44
|
+
method: 'get'
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* 修改消防演练回放记录
|
|
50
|
+
* @param {Object} data - 修改数据
|
|
51
|
+
* @param {string} data._id - 记录 ID
|
|
52
|
+
*/
|
|
53
|
+
export function updateOne(data) {
|
|
54
|
+
return requestShow({
|
|
55
|
+
url: `${baseUrl}/${data._id}`,
|
|
56
|
+
method: 'put',
|
|
57
|
+
data
|
|
58
|
+
})
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 删除消防演练回放记录
|
|
63
|
+
* @param {string} id - 记录 ID
|
|
64
|
+
*/
|
|
65
|
+
export function deleteOne(id) {
|
|
66
|
+
return requestShow({
|
|
67
|
+
url: `${baseUrl}/${id}`,
|
|
68
|
+
method: 'delete'
|
|
69
|
+
})
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* 批量删除消防演练回放记录
|
|
74
|
+
* @param {Array<string>} ids - 记录 ID 数组
|
|
75
|
+
*/
|
|
76
|
+
export function deleteMany(ids) {
|
|
77
|
+
return requestShow({
|
|
78
|
+
url: baseUrl,
|
|
79
|
+
method: 'delete',
|
|
80
|
+
data: ids
|
|
81
|
+
})
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default {
|
|
85
|
+
list,
|
|
86
|
+
create,
|
|
87
|
+
getOne,
|
|
88
|
+
updateOne,
|
|
89
|
+
deleteOne,
|
|
90
|
+
deleteMany
|
|
91
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
jest.mock('../utils', () => ({
|
|
2
|
+
requestShow: jest.fn()
|
|
3
|
+
}))
|
|
4
|
+
|
|
5
|
+
const { requestShow } = require('../utils')
|
|
6
|
+
const fireDrillRecords = require('./fireDrillRecords').default
|
|
7
|
+
const sdk = require('../index').default
|
|
8
|
+
|
|
9
|
+
describe('fireDrillRecords api', () => {
|
|
10
|
+
afterEach(() => {
|
|
11
|
+
jest.clearAllMocks()
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('lists fire drill records from show backend', () => {
|
|
15
|
+
const query = {
|
|
16
|
+
page: 1,
|
|
17
|
+
limit: 20,
|
|
18
|
+
status: 'finished',
|
|
19
|
+
hierarchyID: 'depart_102030',
|
|
20
|
+
hierarchyPathId: 'root_depart',
|
|
21
|
+
startTimeFrom: 1779253200000,
|
|
22
|
+
startTimeTo: 1779254100000
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fireDrillRecords.list(query)
|
|
26
|
+
|
|
27
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
28
|
+
url: '/fire-drill-records',
|
|
29
|
+
method: 'get',
|
|
30
|
+
params: query
|
|
31
|
+
})
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
test('creates fire drill record', () => {
|
|
35
|
+
const data = {
|
|
36
|
+
name: '东区办公楼消防疏散演练',
|
|
37
|
+
status: 'running',
|
|
38
|
+
startTime: 1779253200000,
|
|
39
|
+
hierarchyID: 'depart_102030',
|
|
40
|
+
hierarchyPaths: ['root_depart', 'depart_102030'],
|
|
41
|
+
planSnapshot: {},
|
|
42
|
+
timelineEvents: [],
|
|
43
|
+
metricsSeries: [],
|
|
44
|
+
routeSnapshots: []
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
fireDrillRecords.create(data)
|
|
48
|
+
|
|
49
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
50
|
+
url: '/fire-drill-records',
|
|
51
|
+
method: 'post',
|
|
52
|
+
data
|
|
53
|
+
})
|
|
54
|
+
})
|
|
55
|
+
|
|
56
|
+
test('updates fire drill record by _id', () => {
|
|
57
|
+
const data = {
|
|
58
|
+
_id: '5e4bb8a8-8c4f-4ad4-a03d-4dfcefa18a57',
|
|
59
|
+
status: 'finished',
|
|
60
|
+
endTime: 1779254100000
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
fireDrillRecords.updateOne(data)
|
|
64
|
+
|
|
65
|
+
expect(requestShow).toHaveBeenCalledWith({
|
|
66
|
+
url: '/fire-drill-records/5e4bb8a8-8c4f-4ad4-a03d-4dfcefa18a57',
|
|
67
|
+
method: 'put',
|
|
68
|
+
data
|
|
69
|
+
})
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
test('exports module from sdk root', () => {
|
|
73
|
+
expect(sdk.fireDrillRecords).toBe(fireDrillRecords)
|
|
74
|
+
})
|
|
75
|
+
})
|
package/index.js
CHANGED
|
@@ -40,6 +40,7 @@ import maintenanceRecord from "./api/maintenanceRecord";
|
|
|
40
40
|
import sensorStatusConfig from "./api/sensorStatusConfig";
|
|
41
41
|
import attendanceRecord from "./api/attendanceRecord";
|
|
42
42
|
import workSchedule from "./api/workSchedule";
|
|
43
|
+
import fireDrillRecords from "./api/fireDrillRecords";
|
|
43
44
|
const api = {
|
|
44
45
|
alarmRecord,
|
|
45
46
|
alarmProgress,
|
|
@@ -80,6 +81,7 @@ const api = {
|
|
|
80
81
|
sensorStatusConfig,
|
|
81
82
|
attendanceRecord,
|
|
82
83
|
workSchedule,
|
|
84
|
+
fireDrillRecords,
|
|
83
85
|
};
|
|
84
86
|
|
|
85
87
|
export default {
|