import { Entity, Column, JoinColumn, ManyToOne, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Command } from "./Command";
import { Profile } from "./Profile";

@Entity("commandSign")
export class CommandSign extends EntityBase {
  @Column({
    nullable: true,
    comment: "คำนำหน้า",
    length: 255,
    default: null,
  })
  prefix: string;

  @Column({
    nullable: true,
    comment: "ชื่อ",
    length: 255,
    default: null,
  })
  firstName: string;

  @Column({
    nullable: true,
    comment: "สกุล",
    length: 255,
    default: null,
  })
  lastName: string;

  @Column({
    nullable: true,
    comment: "ตำแหน่ง",
    length: 255,
    default: null,
  })
  position: string;

  @Column({
    nullable: true,
    comment: "ความเห็น",
    length: 255,
    default: null,
  })
  comment: string;

  @Column({
    comment: "เป็นผู้มีอำนาจลงนาม",
    default: false,
  })
  isSignatory: boolean;

  @Column({
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง command",
  })
  commandId: string;

  @ManyToOne(() => Command, (command) => command.commandSigns)
  @JoinColumn({ name: "commandId" })
  command: Command;

  @Column({
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง profile",
  })
  profileId: string;

  @ManyToOne(() => Profile, (profile) => profile.commandSigns)
  @JoinColumn({ name: "profileId" })
  profile: Profile;
}

export class CreateCommandSign {
  @Column()
  name: string;
}

// export type UpdateCommandSign = Partial<CreateCommandSign>;
