import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { EmployeePosDict } from "./EmployeePosDict";
import { EmployeePosLevel } from "./EmployeePosLevel";
import { EmployeePosition } from "./EmployeePosition";
import { ProfileEmployee } from "./ProfileEmployee";

@Entity("employeePosType")
export class EmployeePosType extends EntityBase {
  @Column({
    nullable: true,
    comment: "ชื่อกลุ่มงาน",
    length: 255,
    default: null,
  })
  posTypeName: string;

  @Column({
    comment: "ระดับของกลุ่มงาน",
  })
  posTypeRank: number;

  @Column({
    nullable: true,
    comment: "ชื่อย่อกลุ่มงาน",
    length: 255,
    default: null,
  })
  posTypeShortName: string;

  @OneToMany(() => EmployeePosLevel, (posLevel) => posLevel.posType)
  posLevels: EmployeePosLevel[];

  @OneToMany(() => EmployeePosition, (position) => position.posType)
  positions: EmployeePosition[];

  @OneToMany(() => EmployeePosDict, (posDict) => posDict.posType)
  posDicts: EmployeePosDict[];

  @OneToMany(() => ProfileEmployee, (profile) => profile.posType)
  profiles: ProfileEmployee[];

  @OneToMany(() => ProfileEmployee, (profile) => profile.posTypeTemp)
  profilesTemp: ProfileEmployee[];
}

export class CreateEmployeePosType {
  @Column()
  posTypeName: string;

  @Column()
  posTypeRank: number;

  @Column()
  posTypeShortName: string;
}

export type UpdateEmployeePosType = Partial<CreateEmployeePosType>;
