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

@Entity("profileDutyHistory")
export class ProfileDutyHistory extends EntityBase {
  @Column({
    nullable: true,
    type: "datetime",
    comment: "เริ่มต้น",
    default: null,
  })
  dateStart: Date;

  @Column({
    nullable: true,
    type: "datetime",
    comment: "สิ้นสุด",
    default: null,
  })
  dateEnd: Date;

  @Column({
    nullable: true,
    comment: "รายละเอียด",
    type: "text",
    default: null,
  })
  detail: string;

  @Column({
    nullable: true,
    comment: "เอกสารอ้างอิง",
    type: "text",
    default: null,
  })
  reference: string;

  @Column({
    nullable: true,
    type: "datetime",
    comment: "เอกสารอ้างอิง (ลงวันที่)",
    default: null,
  })
  refCommandDate: Date;

  @Column({
    nullable: true,
    comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)",
    type: "text",
    default: null,
  })
  refCommandNo: string;

  @Column({
    comment: "แนบไฟล์เอกสาร",
    default: false,
  })
  isUpload: boolean;

  @Column({
    nullable: true,
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง ProfileDuty",
    default: null,
  })
  profileDutyId: string;

  @Column({
    nullable: false,
    comment: "สถานะลบข้อมูล",
    default: false,
  })
  isDeleted: boolean;

  @ManyToOne(() => ProfileDuty, (profileDuty) => profileDuty.profileDutyHistories)
  @JoinColumn({ name: "profileDutyId" })
  histories: ProfileDuty;
}
