// app/model/embargo_policy.js 'use strict'; module.exports = app => { const { INTEGER, STRING, ENUM, TEXT, DATEONLY, DATE, BOOLEAN, BIGINT } = app.Sequelize; const EmbargoPolicy = app.model.define('wms_embargo_policies', { id: { type: INTEGER.UNSIGNED, primaryKey: true, autoIncrement: true, allowNull: false, comment: 'ID', }, policy_name: { type: STRING(100), allowNull: false, comment: '策略名称', }, status: { type: ENUM('ACTIVE', 'INACTIVE', 'PENDING', 'EXPIRED'), allowNull: true, defaultValue: 'PENDING', comment: '状态', }, embargo_scope: { type: TEXT, allowNull: true, comment: '禁运范围(数组)', }, start_date: { type: DATEONLY, allowNull: false, comment: '生效开始日期', }, end_date: { type: DATEONLY, allowNull: true, defaultValue: null, comment: '结束日期', }, is_permanent: { type: BOOLEAN, allowNull: true, defaultValue: false, comment: '是否永久有效', }, description: { type: TEXT, allowNull: true, comment: '策略描述', }, created_by: { type: STRING(50), allowNull: true, comment: '创建人', }, updated_by: { type: STRING(50), allowNull: true, comment: '更新人', }, created_at: { type: DATE, allowNull: true, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, updated_at: { type: DATE, allowNull: true, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '更新时间', }, warehouse_id: { type: BIGINT.UNSIGNED, allowNull: true, defaultValue: null, comment: '仓库ID', }, }, { tableName: 'wms_embargo_policies', timestamps: false, underscored: false, comment: '禁运策略主表', indexes: [ { name: 'idx_status', fields: [ 'status' ], }, { name: 'idx_dates', fields: [ 'start_date', 'end_date' ], }, { name: 'idx_created_at', fields: [ 'created_at' ], }, { name: 'warehouse_id', fields: [ 'warehouse_id' ], }, ], }); return EmbargoPolicy; };