'use strict'; /** * 包材信息模型。 * @param {import('egg').Application} app Egg 应用实例。 * @return {import('sequelize').ModelCtor} Sequelize 模型。 */ module.exports = app => { const { BIGINT, STRING, DECIMAL, TINYINT, INTEGER, DATE } = app.Sequelize; const PackageMaterial = app.model.define('package_material', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, warehouse_id: { type: BIGINT(20).UNSIGNED, allowNull: false, comment: '仓库ID', }, material_code: { type: STRING(64), allowNull: false, comment: '包材编码', }, material_name: { type: STRING(128), allowNull: false, comment: '包材名称', }, material_type: { type: STRING(32), allowNull: true, comment: '包材类型', }, spec: { type: STRING(128), allowNull: true, comment: '规格描述', }, length: { type: DECIMAL(10, 2), allowNull: true, comment: '长度(cm)', }, width: { type: DECIMAL(10, 2), allowNull: true, comment: '宽度(cm)', }, height: { type: DECIMAL(10, 2), allowNull: true, comment: '高度(cm)', }, weight: { type: DECIMAL(10, 3), allowNull: true, comment: '重量(kg)', }, cost_price: { type: DECIMAL(10, 2), allowNull: true, comment: '成本单价', }, status: { type: TINYINT(1), allowNull: false, defaultValue: 1, comment: '状态:0=禁用,1=启用', }, version: { type: INTEGER.UNSIGNED, allowNull: false, defaultValue: 1, comment: '版本号', }, created_at: { type: DATE, allowNull: false, comment: '创建时间', }, updated_at: { type: DATE, allowNull: false, comment: '更新时间', }, }, { tableName: 'wms_package_material', freezeTableName: true, underscored: true, timestamps: true, paranoid: false, createdAt: 'created_at', updatedAt: 'updated_at', comment: '包材信息表', indexes: [ { name: 'idx_wms_package_material_warehouse_id', fields: [ 'warehouse_id' ], }, { name: 'uk_wms_package_material_warehouse_material_code', unique: true, fields: [ 'warehouse_id', 'material_code' ], }, ], }); return PackageMaterial; };