packServer/backend/app/model/workstation.js

43 lines
2.4 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';
/**
* 工作台表模型(workstations)
*
* 一个工作台:绑定若干摄像头(workstation_cameras)+ 若干扫码通道(workstation_scan_channels)。
* `code` 是业务编号(如「1号工作台」),同一用户下唯一。
*/
module.exports = (app) => {
const { BIGINT, STRING, TINYINT, INTEGER } = app.Sequelize;
const Workstation = app.model.define('workstation', {
id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' },
subjectId: { type: BIGINT.UNSIGNED, comment: '所属主体 subjects.id' },
userId: { type: BIGINT.UNSIGNED, comment: '创建人 users.id' },
code: { type: STRING(64), allowNull: false, comment: '工作台编号' },
name: { type: STRING(64), allowNull: false, defaultValue: '', comment: '工作台名称' }, /** 1 散单工作台 2 团购工作台 */
wsType: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '工作台类型' },
/** 录制范围(团购以扫码时间为基准,散单以任务结束时间为基准) */
recordBeforeSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 60, comment: '录制范围:触发点之前秒数' },
recordAfterSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 60, comment: '录制范围:触发点之后秒数' },
recordMaxSec: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 240, comment: '最大录制时长(秒)' }, status: { type: TINYINT.UNSIGNED, allowNull: false, defaultValue: 1, comment: '状态:1启用 0停用' },
remark: { type: STRING(255), comment: '备注' },
// ↓ 合成画面画布(默认 1920×1080)
canvasWidth: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1920, comment: '合成画布宽' },
canvasHeight: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1080, comment: '合成画布高' },
}, {
tableName: 'workstations',
paranoid: true,
comment: '工作台表',
});
Workstation.associate = function() {
app.model.Workstation.belongsTo(app.model.User, { foreignKey: 'user_id', as: 'user' });
app.model.Workstation.hasMany(app.model.WorkstationCamera, { foreignKey: 'workstation_id', as: 'cameraLinks' });
app.model.Workstation.hasMany(app.model.WorkstationScanChannel, { foreignKey: 'workstation_id', as: 'scanChannelLinks' });
};
return Workstation;
};