const { DataTypes } = require('sequelize'); const sequelize = require('./index').sequelize; const Contact = sequelize.define('Contact', { id: { type: DataTypes.INTEGER, primaryKey: true, autoIncrement: true }, name: { type: DataTypes.STRING(100), allowNull: false, comment: '联系人姓名' }, email: { type: DataTypes.STRING(255), allowNull: false, validate: { isEmail: true }, comment: '联系人邮箱' }, phone: { type: DataTypes.STRING(20), allowNull: true, comment: '联系电话' }, company: { type: DataTypes.STRING(200), allowNull: true, comment: '公司名称' }, subject: { type: DataTypes.STRING(200), allowNull: false, comment: '留言主题' }, message: { type: DataTypes.TEXT, allowNull: false, comment: '留言内容' }, status: { type: DataTypes.INTEGER, defaultValue: 0, comment: '处理状态:0-未处理,1-已处理' }, isEmailSent: { type: DataTypes.BOOLEAN, defaultValue: false, comment: '是否已发送邮件通知' } }, { tableName: 'contacts', timestamps: true, indexes: [ { fields: ['email'] }, { fields: ['status'] }, { fields: ['createdAt'] } ] }); module.exports = Contact;