import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { OrgChild1 } from "./OrgChild1"; import { OrgRevision } from "./OrgRevision"; import { OrgChild2 } from "./OrgChild2"; import { OrgChild3 } from "./OrgChild3"; import { OrgChild4 } from "./OrgChild4"; import { PosMaster } from "./PosMaster"; import { PermissionOrg } from "./PermissionOrg"; enum OrgRootRank { DEPARTMENT = "DEPARTMENT", OFFICE = "OFFICE", DIVISION = "DIVISION", SECTION = "SECTION", } @Entity("orgRoot") export class OrgRoot extends EntityBase { @Column({ nullable: true, comment: "MisId", length: 255, default: null, }) misId: string; @Column({ nullable: true, comment: "ชื่อหน่วยงาน", length: 255, default: null, }) orgRootName: string; @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน", length: 16, default: null, }) orgRootShortName: string; @Column({ nullable: true, comment: "รหัสหน่วยงาน", length: 8, default: null, }) orgRootCode: string; @Column({ nullable: true, comment: "ระดับของหน่วยงาน", type: "enum", enum: OrgRootRank, default: null, }) orgRootRank: OrgRootRank; @Column({ nullable: true, comment: "ระดับส่วนราชการsub", default: null, }) orgRootRankSub: string; @Column({ nullable: true, comment: "ลำดับที่ของหน่วยงาน", default: null, }) orgRootOrder: number; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", default: null, }) orgRootPhoneEx: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", default: null, }) orgRootPhoneIn: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรสาร", default: null, }) orgRootFax: string; @Column({ nullable: true, length: 40, comment: "รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้าง โครงสร้างใหม่ที่ทำสำเนากับโครงสร้างเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขโครงสร้างย้อนหลังได้", default: null, }) ancestorDNA: string; @Column({ nullable: true, length: 255, comment: "หน้าที่ความรับผิดชอบ", default: null, }) responsibility: string; @Column({ comment: "เป็นปลัด", default: false, }) isDeputy: boolean; @Column({ comment: "สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร", default: false, }) isCommission: boolean; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgRevision", }) orgRevisionId: string; @Column({ nullable: true, length: 5, comment: "DEPARTMENT_CODE", default: null, }) DEPARTMENT_CODE: string; @Column({ nullable: true, length: 5, comment: "DIVISION_CODE", default: null, }) DIVISION_CODE: string; @Column({ nullable: true, length: 5, comment: "SECTION_CODE", default: null, }) SECTION_CODE: string; @Column({ nullable: true, length: 5, comment: "JOB_CODE", default: null, }) JOB_CODE: string; @ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots) @JoinColumn({ name: "orgRevisionId" }) orgRevision: OrgRevision; @OneToMany(() => PosMaster, (posMaster) => posMaster.orgRoot) posMasters: PosMaster[]; @OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot) orgChild1s: OrgChild1[]; @OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1) orgChild2s: OrgChild2[]; @OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1) orgChild3s: OrgChild3[]; @OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1) orgChild4s: OrgChild4[]; @OneToMany(() => PermissionOrg, (permissionOrg) => permissionOrg.orgRootTree) permissionOrgRoots: PermissionOrg[]; } export class CreateOrgRoot { @Column() orgRootName: string; @Column() orgRootShortName: string; @Column() orgRootCode: string; @Column() orgRootRank: OrgRootRank; @Column() orgRootRankSub?: string; @Column() DEPARTMENT_CODE?: string; @Column() DIVISION_CODE?: string; @Column() SECTION_CODE?: string; @Column() JOB_CODE?: string; @Column() orgRootPhoneEx?: string; @Column() orgRootPhoneIn?: string; @Column() orgRootFax?: string; @Column() responsibility?: string; @Column("uuid") orgRevisionId: string; @Column() isDeputy: boolean; @Column() isCommission: boolean; @Column() misId?: string; } export type UpdateOrgRoot = Partial & { orgRootRank?: OrgRootRank };