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

@Entity('taxi_rides')
export class TaxiRideEntity {
    @PrimaryGeneratedColumn() id: number;
    @Index()
    @Column()
    customer_character_id: number;
    @Column({ type: 'float' }) pickup_x: number;
    @Column({ type: 'float' }) pickup_y: number;
    @Column({ type: 'float' }) pickup_z: number;
    @Column({ type: 'float' }) destination_x: number;
    @Column({ type: 'float' }) destination_y: number;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Index()
    @Column({ nullable: true })
    taxi_character_id: number;
    @Index()
    @Column({ nullable: true })
    taxi_company_id: number;
    @Column({ nullable: true, type: 'tinyint', width: 1 }) completed: boolean;
    @Column({ nullable: true, type: 'tinyint' }) rating: number;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({ name: 'customer_character_id' })
    customerCharacter?: CharacterEntity;

    @ManyToOne(() => CharacterEntity)
    @JoinColumn({ name: 'taxi_character_id' })
    taxiCharacter?: CharacterEntity;

    @ManyToOne(() => CompanyEntity)
    @JoinColumn({ name: 'taxi_company_id' })
    taxiCompany?: CompanyEntity;
}
