import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { CharacterEntity } from './character.entity';

@Entity('reports')
export class ReportEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 256, nullable: false }) report: string;
    @Column({ type: 'int', nullable: false }) character_id: number;
    @Column({ type: 'int', nullable: false }) account_id: number;
    @Column({ type: 'int', nullable: true, default: null }) reported_character_id?: number | null;
    @Column({ type: 'int', nullable: true, default: null }) reported_account_id?: number | null;
    @Column({ type: 'datetime', nullable: false, default: () => 'CURRENT_TIMESTAMP()' }) created: Date;
    @Column({ type: 'datetime', nullable: true, default: null }) time_handled?: Date | null;
    @Column({ type: 'varchar', length: 20, nullable: true, default: null }) handled?: string;
    @Column({ type: 'varchar', length: 256, nullable: true, default: null }) handled_reason?: string | null;
    @Column({ type: 'int', nullable: true, default: null }) handler_account_id?: number | null;
    @Column({ type: 'varchar', length: 200, nullable: false }) admins_online: string;
    @Column({ type: 'varchar', length: 130, nullable: false }) location: string;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({
        name: 'reported_character_id',
        referencedColumnName: 'id',
    })
    reported: {
        name: string;
    };

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