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

@Entity("permissionProfile")
export class PermissionProfile extends EntityBase {
  @Column({
    length: 40,
    comment: "คีย์นอก(FK)ของตาราง orgRoot",
  })
  orgRootId: string;

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

  @Column({
    comment: "สิทธิ์การแก้ไข",
    default: false,
  })
  isEdit: boolean;

  @Column({
    comment: "สิทธิ์การตรวจสอบ",
    default: false,
  })
  isCheck: boolean;

  @ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.permissionProfileRoots)
  @JoinColumn({ name: "orgRootId" })
  orgRootTree: OrgRoot;

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