import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { OrgRoot } from "./OrgRoot"; import { OrgChild1 } from "./OrgChild1"; import { OrgChild2 } from "./OrgChild2"; import { OrgChild3 } from "./OrgChild3"; import { OrgRevision } from "./OrgRevision"; import { PosMaster } from "./PosMaster"; enum OrgChild4Rank { DEPARTMENT = "DEPARTMENT", OFFICE = "OFFICE", DIVISION = "DIVISION", SECTION = "SECTION", } @Entity("orgChild4") export class OrgChild4 extends EntityBase { @Column({ nullable: true, comment: "ชื่อส่วนราชการ", length: 255, default: null, }) orgChild4Name: string; @Column({ nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, default: null, }) orgChild4ShortName: string; @Column({ nullable: true, comment: "รหัสส่วนราชการ", length: 8, default: null, }) orgChild4Code: string; @Column({ nullable: true, comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild4Rank, default: null, }) orgChild4Rank: OrgChild4Rank; @Column({ nullable: true, comment: "ระดับส่วนราชการsub", default: null, }) orgChild4RankSub: string; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", default: null, }) orgChild4Order: number; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", default: null, }) orgChild4PhoneEx: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", default: null, }) orgChild4PhoneIn: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรสาร", default: null, }) orgChild4Fax: string; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgRoot", }) orgRootId: string; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgChild1", }) orgChild1Id: string; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgChild2", }) orgChild2Id: string; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgChild3", }) orgChild3Id: string; @Column({ length: 40, comment: "คีย์นอก(FK)ของตาราง orgRevision", }) orgRevisionId: string; @Column({ nullable: true, length: 40, comment: "รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้าง โครงสร้างใหม่ที่ทำสำเนากับโครงสร้างเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขโครงสร้างย้อนหลังได้", default: null, }) ancestorDNA: string; @Column({ nullable: true, length: 255, comment: "หน้าที่ความรับผิดชอบ", default: null, }) responsibility: string; @ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild4s) @JoinColumn({ name: "orgRevisionId" }) orgRevision: OrgRevision; @ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild4s) @JoinColumn({ name: "orgRootId" }) orgRoot: OrgRoot; @ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild4s) @JoinColumn({ name: "orgChild1Id" }) orgChild1: OrgChild1; @ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild4s) @JoinColumn({ name: "orgChild2Id" }) orgChild2: OrgChild2; @ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.orgChild4s) @JoinColumn({ name: "orgChild3Id" }) orgChild3: OrgChild3; @OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild4) posMasters: PosMaster[]; } export class CreateOrgChild4 { @Column() orgChild4Name: string; @Column() orgChild4ShortName: string; @Column() orgChild4Code: string; @Column() orgChild4Rank: string; @Column() orgChild4RankSub?: string; @Column() orgChild4PhoneEx?: string; @Column() orgChild4PhoneIn?: string; @Column() orgChild4Fax?: string; @Column("uuid") orgChild3Id: string; @Column() responsibility?: string; } export type UpdateOrgChild4 = Partial;