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

@Entity('company_positions')
export class CompanyPositionEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column() company_id: number;
    @Column() sort_id: number;
    @Column({ type: 'varchar', length: 64 }) name: string;
    @Column() modify_power: number;
    @Column() needed_modify_power: number;
    @Column() hourly_pay: number;

    @ManyToOne(() => CompanyEntity, (company) => company.positions)
    @JoinColumn({ name: 'company_id' })
    company: CompanyEntity;

    @ManyToMany(() => CharacterEntity, (character) => character.companyPositions)
    @JoinTable({
        name: 'character_company_positions',
        joinColumn: { name: 'company_position_id' },
        inverseJoinColumn: { name: 'character_id' },
    })
    employees: CharacterEntity[];

    permissions: {
        id: number;
        name: string;
        description: string;
    }[] = [];
}
