// app/model/warehouse_log.js 'use strict'; module.exports = app => { const { STRING, INTEGER, BIGINT, TEXT, DATE } = app.Sequelize; const WarehouseLog = app.model.define('warehouse_log', { id: { type: BIGINT(20).UNSIGNED, primaryKey: true, autoIncrement: true, }, log_id: { type: STRING(32), allowNull: false, unique: true, field: 'log_id', comment: '日志唯一ID(WL-{timestamp}-{random})', }, app_key: { type: STRING(64), allowNull: true, field: 'app_key', comment: 'API 应用 AppKey', }, method: { type: STRING(100), allowNull: true, comment: '请求方法名(如 inbox.push)', }, warehouse_id: { type: INTEGER(10), allowNull: true, field: 'warehouse_id', comment: '仓库 ID', }, url: { type: TEXT, allowNull: true, comment: '请求 URL', }, http_status: { type: INTEGER(5), allowNull: true, field: 'http_status', comment: 'HTTP 状态码', }, body: { type: TEXT('long'), allowNull: true, comment: '请求体(最大 65535 字符)', }, result: { type: TEXT('long'), allowNull: true, comment: '响应体(最大 65535 字符)', }, use_time: { type: INTEGER(12), allowNull: true, field: 'use_time', comment: '耗时(毫秒)', }, created_at: { type: DATE, allowNull: true, field: 'created_at', comment: '创建时间', }, updated_at: { type: DATE, allowNull: true, field: 'updated_at', comment: '更新时间', }, }, { tableName: 'wms_warehouse_log', freezeTableName: true, underscored: true, timestamps: true, createdAt: 'created_at', updatedAt: 'updated_at', comment: '仓库开放 API 请求日志表', indexes: [ { name: 'uk_log_id', unique: true, fields: [ 'log_id' ], }, { name: 'idx_app_key', fields: [ 'app_key' ], }, { name: 'idx_method', fields: [ 'method' ], }, { name: 'idx_warehouse_id', fields: [ 'warehouse_id' ], }, { name: 'idx_created_at', fields: [ 'created_at' ], }, ], }); return WarehouseLog; };