import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { OrgRoot } from "./OrgRoot"; import { OrgChild2 } from "./OrgChild2"; import { OrgChild3 } from "./OrgChild3"; import { OrgChild4 } from "./OrgChild4"; // ENUM orgChild1Rank enum OrgChild1Rank { DEPARTMENT = "department", OFFICE = "office", DIVISION = "division", SECTION = "section", } export class OrgChild1 extends EntityBase { // @Column({ // comment: "", // length: 40, // default: "00000000-0000-0000-0000-000000000000", // }) // orgChild1Id: string; @Column({ nullable: true, comment: "ชื่อส่วนราชการ", length: 255, default: "string", }) orgChild1Name: string; @Column({ nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, default: "string", }) orgChild1ShortName: string; @Column({ nullable: true, comment: "รหัสส่วนราชการ", length: 8, default: "string", }) orgChild1Code: string; @Column({ nullable: true, comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild1Rank, // default: OrgChild1Rank.DEPARTMENT, }) orgChild1Rank: OrgChild1Rank; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", }) orgChild1Order: number; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", }) orgChild1PhoneEx: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", }) orgChild1PhoneIn: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรสาร", }) orgChild1Fax: string; @Column({ nullable: true, type: "tinyint", comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0 }) orgChild1IsNormal: number; @Column({ length: 40, default: "00000000-0000-0000-0000-000000000000", }) fkOrgRootId: string; @ManyToOne(() => OrgRoot, orgRoot => orgRoot.orgChild1s) @JoinColumn({ name: "fkOrgRootId" }) orgRoot: OrgRoot; //child table 2,3,4 @OneToMany(() => OrgChild2, orgChild2 => orgChild2.orgChild1) orgChild2s: OrgChild2[]; @OneToMany(() => OrgChild3, orgChild3 => orgChild3.orgChild1) orgChild3s: OrgChild3[]; @OneToMany(() => OrgChild4, orgChild4 => orgChild4.orgChild1) orgChild4s: OrgChild4[]; } export type UpdateOrgChild1 = Partial;