import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { AuthSys } from "./AuthSys"; import { AuthRole } from "./AuthRole"; @Entity("authRoleAttr") export class AuthRoleAttr extends EntityBase { @Column({ nullable: true, comment: "ความเป็นเจ้าของ (Ownership)", length: 255, default: null, }) attrOwnership: string; @Column({ comment: "สิทธิ์ดำเนินการ (Permission) การ Create", default: false, }) attrIsCreate: boolean; @Column({ comment: "สิทธิ์ดำเนินการ (Permission) การ List", default: false, }) attrIsList: boolean; @Column({ comment: "สิทธิ์ดำเนินการ (Permission) การ Get", default: false, }) attrIsGet: boolean; @Column({ comment: "สิทธิ์ดำเนินการ (Permission) การ Update", default: false, }) attrIsUpdate: boolean; @Column({ comment: "สิทธิ์ดำเนินการ (Permission) การ Delete", default: false, }) attrIsDelete: boolean; @Column({ nullable: true, comment: "สิทธิการเข้าถึง(Privilege)", length: 255, default: null, }) attrPrivilege: string; @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง AuthRole", default: null, }) authRoleId: string; @Column({ nullable: true, length: 255, comment: "คีย์นอก(FK)ของตาราง AuthSys", default: null, }) authSysId: string; @Column({ nullable: true, length: 255, comment: "Root", default: null, }) parentNode?: string; @ManyToOne(() => AuthSys, (authSys) => authSys.authRoleAttrs) @JoinColumn({ name: "authSysId" }) authRoleAttrForSys: AuthSys; @ManyToOne(() => AuthRole, (authRole) => authRole.authRoles) @JoinColumn({ name: "authRoleId" }) authRoleAttrForRole: AuthRole; } export class CreateAuthRoleAttr { @Column() attrOwnership: string; @Column() attrIsCreate: boolean; @Column() attrIsList: boolean; @Column() attrIsGet: boolean; @Column() attrIsUpdate: boolean; @Column() attrIsDelete: boolean; @Column() attrPrivilege: string; @Column("uuid") authRoleId: string; @Column("uuid") authSysId: string; @Column() parentNode?: string | null; } export type UpdateAuthRoleAttr = Partial;