// app/model/print_template.js 'use strict'; module.exports = app => { const { BIGINT, STRING, INTEGER, BOOLEAN, JSON, DATE, DATEONLY } = app.Sequelize; const SUPPORTED_BUSINESS_TYPES = [ 'STOCK', 'RECEIPT', 'PICKING', 'OUTBOUND', 'ENTRY_ORDER' ]; const PrintTemplate = app.model.define('print_template', { id: { type: BIGINT(20), primaryKey: true, autoIncrement: true, comment: '主键ID', }, template_name: { type: STRING(100), allowNull: false, comment: '模板名称', }, platform: { type: STRING(50), allowNull: false, comment: '所属平台(抖音、拼多多、快手等)', }, template_type: { type: STRING(50), allowNull: false, comment: '模板类型:STANDARD-标准模板,CUSTOM-自定义模板', }, template_url: { type: STRING(500), allowNull: false, comment: '模板URL地址', }, template_content: { type: JSON, comment: '模板内容(JSON格式)', }, page_width: { type: INTEGER(11), defaultValue: 76, comment: '页面宽度(mm)', }, page_height: { type: INTEGER(11), defaultValue: 130, comment: '页面高度(mm)', }, warehouse_id: { type: BIGINT(20).UNSIGNED, comment: '关联仓库ID', }, is_default: { type: BOOLEAN, defaultValue: false, comment: '是否默认模板:0-否,1-是', }, status: { type: STRING(20), defaultValue: 'ACTIVE', comment: '状态:ACTIVE-启用,DISABLED-禁用', }, create_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, update_at: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP'), comment: '更新时间', }, business_type: { type: STRING(10), allowNull: false, comment: '类型', validate: { notEmpty: true, isIn: [ SUPPORTED_BUSINESS_TYPES ], }, }, delete_at: { type: DATEONLY, comment: '删除时间', }, }, { timestamps: false, tableName: 'wms_print_template', comment: '打印模板配置表', }); return PrintTemplate; };