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

@Entity("profileDisciplineHistory")
export class ProfileDisciplineHistory extends EntityBase {
  @Column({
    nullable: true,
    type: "datetime",
    comment: "วันที่",
    default: null,
  })
  date: Date;

  @Column({
    length: 40,
    comment: "ล้างมลทิน",
    type: "uuid",
  })
  profileDisciplineId: string;

  @Column({
    nullable: true,
    comment: "ระดับความผิด",
    type: "text",
    default: null,
  })
  level: string;

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

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

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

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

  @Column({
    nullable: true,
    comment: "ล้างมลทิน",
    type: "text",
    default: null,
  })
  unStigma: string;

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

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

  @ManyToOne(
    () => ProfileDiscipline,
    (profileDiscipline) => profileDiscipline.profileDisciplineHistories,
  )
  @JoinColumn({ name: "profileDisciplineId" })
  histories: ProfileDiscipline;
}
