WMS_MAIN/app/model/pack_task_packer.js

79 lines
2.0 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';
module.exports = app => {
const { STRING, BIGINT, DATE, TINYINT } = app.Sequelize;
const PackTaskPacker = app.model.define('pack_task_packer', {
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',
},
account_id: {
type: BIGINT(20).UNSIGNED,
allowNull: true,
comment: '账号ID,关联 wms_account.id;未知账号为 NULL(唯一索引对 NULL 不生效,允许多名无账号打包人)',
},
account_name: {
type: STRING(128),
allowNull: false,
comment: '账号姓名快照',
},
seq: {
type: TINYINT.UNSIGNED,
allowNull: false,
defaultValue: 0,
comment: '排序序号',
},
create_time: {
type: DATE,
allowNull: false,
comment: '创建时间',
},
update_time: {
type: DATE,
allowNull: false,
comment: '更新时间',
},
deleted_at: {
type: DATE,
allowNull: true,
comment: '删除时间',
},
}, {
tableName: 'wms_pack_task_packer',
timestamps: true,
createdAt: 'create_time',
updatedAt: 'update_time',
paranoid: true,
deletedAt: 'deleted_at',
comment: '打包任务-打包人关系表',
indexes: [
{ name: 'uix_pack_task_account', fields: [ 'pack_task_id', 'account_id' ], unique: true },
{ name: 'idx_account_id', fields: [ 'account_id' ] },
{ name: 'idx_pack_task_id', fields: [ 'pack_task_id' ] },
],
});
PackTaskPacker.associate = () => {
app.model.PackTaskPacker.belongsTo(app.model.PackTask, {
foreignKey: 'pack_task_id',
targetKey: 'id',
as: 'packTask',
});
app.model.PackTaskPacker.belongsTo(app.model.Account, {
foreignKey: 'account_id',
targetKey: 'id',
as: 'account',
});
};
return PackTaskPacker;
};