import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  Index,
} from 'typeorm';

@Entity('notification_events')
export class NotificationEvent {
  @PrimaryGeneratedColumn({ type: 'bigint' })
  id: number;

  @Column()
  template_id: number;

  @Column()
  recipient_user_id: number;

  @Column({
    type: 'enum',
    enum: ['job_post', 'job_application', 'company'],
  })
  reference_type: 'job_post' | 'job_application' | 'company';

  @Column()
  reference_id: number;

  @Column({ type: 'json', nullable: true })
  payload: any;

  @Column({
    type: 'enum',
    enum: ['pending', 'sent', 'failed'],
    default: 'pending',
  })
  status: 'pending' | 'sent' | 'failed';

  @Column({ type: 'tinyint', width: 1, default: 0 })
  is_read: number;

  @Column({ type: 'int', default: 0 })
  retry_count: number;

  @CreateDateColumn()
  created_at: Date;

  @Column({ type: 'datetime', nullable: true })
  processed_at: Date;
}
