import { Column, Entity, Index, JoinColumn, ManyToOne, OneToMany, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterEntity } from './character.entity';
import { NonEmergencyCallResponseEntity } from './non-emergency-call-response.entity';

@Entity('non_emergency_calls')
export class NonEmergencyCallEntity {
    @PrimaryGeneratedColumn() id: number;
    @Index()
    @Column()
    character_id: number;
    @Column({ type: 'varchar', length: 32 }) character_name: string;
    @Column({ type: 'varchar', length: 32 }) phone_number: string;
    @Column({ type: 'varchar', length: 128 }) location: string;
    @Column({ type: 'text' }) non_emergency: string;
    @Column({ type: 'tinyint', width: 1 }) police: boolean;
    @Column({ type: 'tinyint', width: 1 }) fire: boolean;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) date: Date;

    @OneToMany(() => NonEmergencyCallResponseEntity, (responder) => responder.non_emergency_call)
    responders?: NonEmergencyCallResponseEntity[];

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({ name: 'character_id' })
    character?: CharacterEntity;
}
