- 新增 camera model username/password 字段 - 新增 osd_client.js OSD 客户端库 - 工作台打包时自动叠加 OSD 信息到摄像头(带 Redis 缓存去重) - 新增迁移脚本:摄像头用户名密码字段
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
'use strict';
|
|
|
|
const MainService = require('../main');
|
|
|
|
class CameraService extends MainService {
|
|
constructor(ctx) {
|
|
super(ctx);
|
|
const _noNeedLogin = '';
|
|
const _noNeedRight = 'list,detail,setOsd';
|
|
const _noNeedLog = '*';
|
|
const _noNeedAuth = 'list,detail,setOsd';
|
|
this.systemInit(_noNeedLogin, _noNeedRight, _noNeedLog, _noNeedAuth);
|
|
}
|
|
|
|
async list(data) {
|
|
try {
|
|
const result = await this.service.systems.camera.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.camera.detail(parseInt(id)));
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async create(data) {
|
|
try {
|
|
return this.success('创建成功', await this.service.systems.camera.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.camera.update(parseInt(id), fields));
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async setOsd(data) {
|
|
try {
|
|
return this.success('设置成功', await this.service.systems.camera.setOsd(data));
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
|
|
async delete(data) {
|
|
try {
|
|
const { id } = data || {};
|
|
if (!id) return this.fail('ID不能为空');
|
|
await this.service.systems.camera.delete(parseInt(id));
|
|
return this.success('删除成功');
|
|
} catch (e) { return this.fail(e.message); }
|
|
}
|
|
}
|
|
|
|
module.exports = CameraService;
|