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

@Entity("stateOperatorUser")
export class StateOperatorUser extends EntityBase {
  @Column({
    nullable: true,
    comment: "ผู้ดำเนินการ",
    length: 255,
    default: null,
  })
  operator: string;

  @Column({
    nullable: true,
    comment: "ผู้ใช้งาน",
    length: 255,
    default: null,
  })
  profileType: string;

  @Column({
    nullable: true,
    comment: "ลำดับ",
    default: null,
  })
  order: number;

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

  @ManyToOne(() => Workflow, (workflow) => workflow.stateOperatorUsers)
  @JoinColumn({ name: "workflowId" })
  workflow: Workflow;

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

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

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

  @ManyToOne(() => ProfileEmployee, (profileEmployee) => profileEmployee.stateOperatorUsers)
  @JoinColumn({ name: "profileEmployeeId" })
  profileEmployee: ProfileEmployee;
}
