'use strict'; /** * 邮件发送日志模型,对应 email_logs 表 * @param {Egg.Application} app egg application * @return {object} emailLog model */ module.exports = app => { const { BIGINT, STRING, TINYINT, TEXT, DATE } = app.Sequelize; const EmailLog = app.model.define('email_log', { id: { type: BIGINT.UNSIGNED, primaryKey: true, autoIncrement: true, comment: '主键' }, scene: { type: STRING(30), allowNull: false, defaultValue: 'register', comment: '业务场景' }, to_email: { type: STRING(100), allowNull: false, comment: '收件邮箱' }, subject: { type: STRING(200), comment: '邮件标题' }, content: { type: TEXT, comment: '邮件正文' }, user_id: { type: BIGINT.UNSIGNED, comment: '关联用户ID,注册场景为空' }, ip: { type: STRING(45), comment: '请求方IP' }, status: { type: TINYINT, allowNull: false, defaultValue: 0, comment: '发送状态:1成功 0失败' }, error_msg: { type: STRING(500), comment: '失败原因' }, created_at: { type: DATE, comment: '创建时间' }, updated_at: { type: DATE, comment: '更新时间' }, }); return EmailLog; };