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

@Entity("profileChangeNameHistory")
export class ProfileChangeNameHistory extends EntityBase {
  @Column({
    nullable: true,
    length: 40,
    comment: "Id คำนำหน้า",
    default: null,
  })
  prefixId: string;

  @Column({
    nullable: true,
    length: 40,
    comment: "คำนำหน้า",
    default: null,
  })
  prefix: string;

  @Column({
    nullable: true,
    comment: "ยศ",
    length: 40,
    default: null,
  })
  rank: string;

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

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

  @Column({
    nullable: true,
    length: 100,
    comment: "สถานะ",
    default: null,
  })
  status: string;

  @Column({
    nullable: true,
    length: 40,
    comment: "",
    default: null,
  })
  documentId: string;

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

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

  @ManyToOne(
    () => ProfileChangeName,
    (profileChangeName) => profileChangeName.profileChangeNameHistories,
  )
  @JoinColumn({ name: "profileChangeNameId" })
  histories: ProfileChangeName;
}

export class CreateProfileChangeNameHistory {
  profileChangeNameId: string | null;
  prefixId: string | null;
  prefix: string | null;
  rank: string | null;
  firstName: string | null;
  lastName: string | null;
  status: string | null;
  documentId: string | null;
}

export type UpdateProfileChangeNameHistory = {
  profileChangeNameId?: string | null;
  prefixId?: string | null;
  prefix?: string | null;
  rank?: string | null;
  firstName?: string | null;
  lastName?: string | null;
  status?: string | null;
  documentId?: string | null;
};
