- 新增 model: camera, camera_server - 新增 services: camera, cameraServer (systemMethods + systems) - 新增 pack_task_video 表及录制状态管理 - 7 条迁移: 建表→设备字段→端口拆分→状态枚举
55 lines
1.6 KiB
JavaScript
55 lines
1.6 KiB
JavaScript
'use strict';
|
|
|
|
const MainService = require('../main');
|
|
|
|
class CameraServerService extends MainService {
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
const _noNeedLogin = '';
|
|
const _noNeedRight = 'list,detail';
|
|
const _noNeedLog = '*';
|
|
const _noNeedAuth = 'list,detail';
|
|
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
|
|
}
|
|
|
|
async list(data) {
|
|
try {
|
|
const result = await this.service.systems.cameraServer.list(data || {});
|
|
return this.success('获取成功', result);
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async detail(data) {
|
|
try {
|
|
const { id } = data || {};
|
|
if (!id) return this.fail('ID不能为空');
|
|
return this.success('获取成功', await this.service.systems.cameraServer.detail(parseInt(id)));
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async create(data) {
|
|
try {
|
|
return this.success('创建成功', await this.service.systems.cameraServer.create(data));
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async update(data) {
|
|
try {
|
|
const { id, ...fields } = data || {};
|
|
if (!id) return this.fail('ID不能为空');
|
|
return this.success('更新成功', await this.service.systems.cameraServer.update(parseInt(id), fields));
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async delete(data) {
|
|
try {
|
|
const { id } = data || {};
|
|
if (!id) return this.fail('ID不能为空');
|
|
await this.service.systems.cameraServer.delete(parseInt(id));
|
|
return this.success('删除成功');
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
}
|
|
|
|
module.exports = CameraServerService;
|