import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Position } from "./Position";
import { PosDict } from "./PosDict";

@Entity("posExecutive")
export class PosExecutive extends EntityBase {
  @Column({
    nullable: true,
    comment: "ชื่อตำแหน่งทางการบริหาร",
    length: 255,
    default: null,
  })
  posExecutiveName: string;

  @Column({
    nullable: true,
    comment: "ลำดับความสำคัญ",
    default: null,
  })
  posExecutivePriority: number;

  @OneToMany(() => Position, (position) => position.posExecutive)
  positions: Position[];

  @OneToMany(() => PosDict, (posDict) => posDict.posExecutive)
  posDicts: PosDict[];
}

export class CreatePosExecutive {
  @Column()
  posExecutiveName: string;

  @Column()
  posExecutivePriority: number | null;
}

export type UpdatePosExecutive = Partial<CreatePosExecutive>;
