'use strict'; /** * 对外 API 请求记录模型,对应 api_outbound_logs 表 * 记录 OMS 调用外部 WMS(index.ping / singleitem.synchronize 等)的请求与响应信息,用于排查 * @param {Egg.Application} app egg application * @return {object} apiOutboundLog model */ module.exports = app => { const { BIGINT, STRING, INTEGER, TINYINT, TEXT, DATE } = app.Sequelize; const ApiOutboundLog = app.model.define('api_outbound_log', { id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' }, principal_id: { type: BIGINT.UNSIGNED, comment: '所属主体ID' }, warehouse_id: { type: BIGINT.UNSIGNED, comment: '关联仓库ID' }, warehouse_api_id: { type: BIGINT.UNSIGNED, comment: '使用的接口配置ID' }, api_type: { type: STRING(50), defaultValue: 'qimen', comment: '接口类型' }, method: { type: STRING(100), allowNull: false, comment: 'WMS 方法名' }, url: { type: TEXT, comment: '完整请求地址(sign 已脱敏)' }, request_headers: { type: TEXT, comment: '请求头 JSON' }, request_body: { type: TEXT, comment: '请求报文 JSON' }, response_status: { type: INTEGER, comment: 'HTTP 状态码' }, response_body: { type: TEXT, comment: '响应报文' }, is_success: { type: TINYINT, defaultValue: 0, comment: '传输层是否成功:1是 0否' }, business_code: { type: STRING(32), comment: 'WMS 业务码' }, business_message: { type: STRING(255), comment: 'WMS 业务提示' }, error: { type: TEXT, comment: '异常信息' }, duration: { type: INTEGER, comment: '耗时(毫秒)' }, created_at: { type: DATE, comment: '创建时间' }, updated_at: { type: DATE, comment: '更新时间' }, }); return ApiOutboundLog; };