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

@Entity('contract_parties')
export class ContractPartyEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() contract_id: number;
    @Column() entity_type_id: number;
    @Column() entity_id: number;
    @Column({ type: 'datetime', nullable: true }) signed: Date | null;
    @Column({ type: 'varchar', length: 128, nullable: true }) entity_name: string | null;
    @Column({ type: 'varchar', length: 128, nullable: true }) entity_note: string | null;
    @Column({ type: 'varchar', length: 64, nullable: true }) stamp: string | null;
    @Column({ type: 'varchar', length: 24, nullable: true }) signature: string | null;
    @Column({ type: 'varchar', length: 32, nullable: true }) signature_font: string | null;
    @Column({ type: 'int', nullable: true }) character_id: number | null;
    @Column({ type: 'varchar', length: 64, nullable: false }) name: string;

    @ManyToOne(() => ContractEntity, (contract) => contract.parties)
    @JoinColumn({ name: 'contract_id' })
    contract: ContractEntity;
}
