'use strict'; module.exports = app => { const { STRING, BIGINT, DATE } = app.Sequelize; const PackTaskVideo = app.model.define('pack_task_video', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键ID', }, pack_task_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '打包任务ID,关联 wms_pack_task.id', }, camera_id: { type: BIGINT(20).UNSIGNED, allowNull: true, comment: '摄像头设备ID,关联 wms_camera.id', }, video_url: { type: STRING(500), allowNull: false, comment: '视频地址(录像回放URL)', }, status: { type: STRING(20), allowNull: false, defaultValue: 'created', comment: '状态:created-已创建 recording-录制中 completed-已完成 failed-失败', }, remark: { type: STRING(500), allowNull: true, comment: '备注', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, deleted_at: { type: DATE, allowNull: true, comment: '软删除时间', }, }, { tableName: 'wms_pack_task_video', timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', paranoid: true, deletedAt: 'deleted_at', comment: '打包任务视频记录表', indexes: [ { name: 'idx_pack_task_id', fields: [ 'pack_task_id' ] }, { name: 'idx_camera_id', fields: [ 'camera_id' ] }, { name: 'idx_deleted_at', fields: [ 'deleted_at' ] }, ], }); PackTaskVideo.associate = () => { app.model.PackTaskVideo.belongsTo(app.model.PackTask, { foreignKey: 'pack_task_id', targetKey: 'id', as: 'packTask', }); app.model.PackTaskVideo.belongsTo(app.model.Camera, { foreignKey: 'camera_id', targetKey: 'id', as: 'camera', }); }; return PackTaskVideo; };