'use strict'; module.exports = app => { const { STRING, BIGINT, DATE, TINYINT, ENUM, JSON: JSON_TYPE } = app.Sequelize; const Workbench = app.model.define('workbench', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, name: { type: STRING(100), allowNull: false, comment: '工作台名称(用户自定义)', }, barcode: { type: STRING(100), allowNull: true, comment: '工作台条码(用户自定义,仓库内唯一)', }, status: { type: TINYINT, allowNull: false, defaultValue: 1, comment: '状态:0-禁用 1-启用', }, type: { type: ENUM('personal', 'group'), allowNull: false, defaultValue: 'personal', comment: '工作台类型:personal-个人工作台 group-团体工作台', }, remark: { type: STRING(500), allowNull: true, comment: '备注', }, device_ids: { type: JSON_TYPE, allowNull: true, comment: '设备ID列表,如 [1,2,3],触发打包任务时透传到 wms_pack_task.device_ids', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, deleted_at: { type: DATE, allowNull: true, comment: '软删除时间', }, }, { tableName: 'wms_workbench', timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', paranoid: true, deletedAt: 'deleted_at', comment: '工作台表', indexes: [ { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ] }, { name: 'idx_barcode', fields: [ 'barcode' ] }, { name: 'uk_warehouse_barcode', unique: true, fields: [ 'warehouse_id', 'barcode', 'deleted_at' ] }, { name: 'idx_deleted_at', fields: [ 'deleted_at' ] }, ], }); return Workbench; };