import { Column, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn } from 'typeorm';
import { NonEmergencyCallEntity } from './non-emergency-call.entity';
import { CharacterEntity } from './character.entity';

@Entity('non_emergency_call_responses')
export class NonEmergencyCallResponseEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() non_emergency_call_id: number;
    @Column() character_id: number;
    @Column({ type: 'varchar', length: 128 }) responder_name: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) date: Date;

    @ManyToOne(() => NonEmergencyCallEntity, (call) => call.responders)
    @JoinColumn({ name: 'emergency_call_id' })
    non_emergency_call: NonEmergencyCallEntity;

    @OneToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'character_id',
        referencedColumnName: 'id',
    })
    character: CharacterEntity;
}
