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

@Entity('notifications')
export class Notification {
  @PrimaryGeneratedColumn({ type: 'bigint', unsigned: true })
  id: number;

  @Index()
  @Column({ name: 'user_id', type: 'bigint', unsigned: true, comment: '用户ID' })
  userId: number;

  @Column({ length: 200, comment: '标题' })
  title: string;

  @Column({ type: 'text', comment: '内容' })
  content: string;

  @Index()
  @Column({ type: 'enum', enum: ['order', 'system', 'promotion', 'review'], comment: '类型' })
  type: 'order' | 'system' | 'promotion' | 'review';

  @Index()
  @Column({ name: 'is_read', type: 'boolean', default: false, comment: '是否已读' })
  isRead: boolean;

  @Column({ type: 'json', nullable: true, comment: '附加数据' })
  extra: object;

  @CreateDateColumn({ name: 'created_at', comment: '创建时间' })
  createdAt: Date;
}
