import { Table, Column, Model, DataType, Index } from 'sequelize-typescript'; export enum ReminderType { CHALLENGE_ENCOURAGEMENT = 'challenge_encouragement', // 已参与挑战用户的鼓励推送 CHALLENGE_INVITATION = 'challenge_invitation', // 未参与挑战用户的邀请推送 GENERAL_INVITATION = 'general_invitation', // 无userId用户的通用邀请 } @Table({ tableName: 't_push_reminder_history', underscored: true, }) export class PushReminderHistory extends Model { @Column({ type: DataType.UUID, defaultValue: DataType.UUIDV4, primaryKey: true, }) declare id: string; @Column({ type: DataType.STRING, allowNull: true, comment: '用户ID,可能为空', }) declare userId: string | null; @Column({ type: DataType.STRING, allowNull: false, comment: '设备推送令牌', }) declare deviceToken: string; @Column({ type: DataType.ENUM(...Object.values(ReminderType)), allowNull: false, comment: '提醒类型', }) declare reminderType: ReminderType; @Column({ type: DataType.DATE, allowNull: false, comment: '最后发送时间', }) declare lastSentAt: Date; @Column({ type: DataType.INTEGER, allowNull: false, defaultValue: 0, comment: '发送次数', }) declare sentCount: number; @Column({ type: DataType.DATE, allowNull: true, comment: '下次可发送时间', }) declare nextAvailableAt: Date | null; @Column({ type: DataType.BOOLEAN, allowNull: false, defaultValue: true, comment: '是否激活', }) declare isActive: boolean; @Column({ type: DataType.DATE, defaultValue: DataType.NOW, }) declare createdAt: Date; @Column({ type: DataType.DATE, defaultValue: DataType.NOW, }) declare updatedAt: Date; }