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

@Entity('user_day_statistics')
@Index(['accountId', 'recordDate'], { unique: true })
export class UserDayStatistics {
  @PrimaryGeneratedColumn()
  id!: number;

  @Column({ name: 'account_id', type: 'int' })
  accountId!: number;

  @Column({ name: 'record_date', type: 'date' })
  recordDate!: Date;

  @Column({ name: 'fans_count', type: 'int', default: 0, comment: '粉丝数' })
  fansCount!: number;

  @Column({ name: 'works_count', type: 'int', default: 0, comment: '作品数' })
  worksCount!: number;

  @Column({ name: 'play_count', type: 'int', default: 0, comment: '播放数' })
  playCount!: number;

  @Column({ name: 'comment_count', type: 'int', default: 0, comment: '评论数' })
  commentCount!: number;

  @Column({ name: 'fans_increase', type: 'int', default: 0, comment: '涨粉数' })
  fansIncrease!: number;

  @Column({ name: 'like_count', type: 'int', default: 0, comment: '点赞数' })
  likeCount!: number;

  @Column({ name: 'share_count', type: 'int', default: 0, comment: '分享数' })
  shareCount!: number;

  @Column({ name: 'collect_count', type: 'int', default: 0, comment: '收藏数' })
  collectCount!: number;

  @Column({ name: 'cover_click_rate', type: 'varchar', length: 50, default: '0', comment: '封面点击率' })
  coverClickRate!: string;

  @Column({ name: 'avg_watch_duration', type: 'varchar', length: 50, default: '0', comment: '平均观看时长（秒）' })
  avgWatchDuration!: string;

  @Column({ name: 'total_watch_duration', type: 'varchar', length: 50, default: '0', comment: '观看总时长（秒）' })
  totalWatchDuration!: string;

  @Column({ name: 'completion_rate', type: 'varchar', length: 50, default: '0', comment: '视频完播率' })
  completionRate!: string;

  @CreateDateColumn({ name: 'created_at' })
  createdAt!: Date;

  @UpdateDateColumn({ name: 'updated_at' })
  updatedAt!: Date;
}
