// app/model/print_log.js 'use strict'; module.exports = app => { const { BIGINT, STRING, TEXT, JSON, DATE } = app.Sequelize; const PrintLog = app.model.define('wms_print_log', { id: { type: BIGINT, primaryKey: true, autoIncrement: true, allowNull: false, comment: '主键ID', }, print_record_id: { type: BIGINT, allowNull: false, comment: '打印记录ID', }, log_type: { type: STRING(20), allowNull: false, comment: '日志类型:CONNECT-连接,PRINT-打印,RETRY-重试,ERROR-错误,SUCCESS-成功', }, log_level: { type: STRING(10), allowNull: true, defaultValue: 'INFO', comment: '日志级别:INFO,WARN,ERROR', }, log_content: { type: TEXT, allowNull: false, comment: '日志内容', }, request_data: { type: JSON, allowNull: true, comment: '请求数据', }, response_data: { type: JSON, allowNull: true, comment: '响应数据', }, websocket_status: { type: STRING(20), allowNull: true, comment: 'WebSocket状态', }, error_code: { type: STRING(50), allowNull: true, comment: '错误代码', }, ip_address: { type: STRING(50), allowNull: true, comment: 'IP地址', }, user_agent: { type: STRING(500), allowNull: true, comment: '用户代理', }, create_time: { type: DATE, allowNull: false, defaultValue: app.Sequelize.literal('CURRENT_TIMESTAMP'), comment: '创建时间', }, }, { tableName: 'wms_print_log', timestamps: false, underscored: false, comment: '打印日志表', indexes: [ { name: 'idx_print_record', fields: [ 'print_record_id' ], }, { name: 'idx_log_type', fields: [ 'log_type' ], }, { name: 'idx_create_time', fields: [ 'create_time' ], }, { name: 'idx_error_code', fields: [ 'error_code' ], }, ], }); return PrintLog; };