packServer/backend/app/model/workstation_camera.js

40 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use strict';
/**
* 工作台 ↔ 摄像头 绑定表(workstation_cameras)
*
* 一个工作台可绑定多个摄像头(一个摄像头也可以出现在多个工作台,绑定关系不独占)。
* 唯一键 `(workstation_id, camera_id)`,解绑是**物理删除**(绑定关系没有保留价值)。
*/
module.exports = (app) => {
const { BIGINT, STRING, INTEGER, TINYINT } = app.Sequelize;
const WorkstationCamera = app.model.define('workstationCamera', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
workstationId: { type: BIGINT.UNSIGNED, allowNull: false, comment: '工作台 id' },
cameraId: { type: BIGINT.UNSIGNED, allowNull: false, comment: '摄像头 id' },
sortNo: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 0, comment: '排序' },
remark: { type: STRING(255), comment: '备注' },
// ↓ 合成画面布局(画布坐标,像素)
x: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '画布左上角 x' },
y: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '画布左上角 y' },
width: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '宽(0=整张画布)' },
height: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '高(0=整张画布)' },
streamType: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 0, comment: '0 主码流 1 子码流' },
zIndex: { type: INTEGER, allowNull: false, defaultValue: 0, comment: '叠放顺序' },
}, {
tableName: 'workstation_cameras',
timestamps: true,
paranoid: false,
comment: '工作台-摄像头绑定表',
});
WorkstationCamera.associate = function() {
app.model.WorkstationCamera.belongsTo(app.model.Workstation, { foreignKey: 'workstation_id', as: 'workstation' });
app.model.WorkstationCamera.belongsTo(app.model.Camera, { foreignKey: 'camera_id', as: 'camera' });
};
return WorkstationCamera;
};