import {
  Entity,
  PrimaryGeneratedColumn,
  Column,
  CreateDateColumn,
  UpdateDateColumn,
  ManyToOne,
  JoinColumn,
} from 'typeorm';
import { FeishuBot } from './feishu-bot.entity';

@Entity('feishu_assessment_sessions')
export class FeishuAssessmentSession {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ name: 'bot_id' })
  botId: string;

  @Column({ name: 'open_id' })
  openId: string;

  @Column({ name: 'assessment_session_id' })
  assessmentSessionId: string;

  @Column({
    type: 'varchar',
    enum: ['active', 'completed', 'cancelled'],
    default: 'active',
  })
  status: 'active' | 'completed' | 'cancelled';

  @Column({ name: 'current_question_index', default: 0 })
  currentQuestionIndex: number;

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

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

  // 关联关系
  @ManyToOne(() => FeishuBot, { onDelete: 'CASCADE' })
  @JoinColumn({ name: 'bot_id' })
  bot: FeishuBot;
}
