import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { OrgChild1 } from "./OrgChild1"; import { OrgChild2 } from "./OrgChild2"; import { OrgChild3 } from "./OrgChild3"; import { OrgChild4 } from "./OrgChild4"; // ENUM orgRootRank enum OrgRootRank { DEPARTMENT = "department", OFFICE = "office", DIVISION = "division", SECTION = "section", } @Entity("orgRoot") export class OrgRoot extends EntityBase { // @Column({ // comment: "", // length: 40, // default: "00000000-0000-0000-0000-000000000000", // }) // orgRootId: string; @Column({ nullable: true, comment: "ชื่อหน่วยงาน", length: 255, default: "string", }) orgRootName: string; @Column({ nullable: true, comment: "ชื่อย่อหน่วยงาน", length: 16, default: "string", }) orgRootShortName: string; @Column({ nullable: true, comment: "รหัสหน่วยงาน", length: 8, default: "string", }) orgRootCode: string; @Column({ nullable: true, comment: "ระดับของหน่วยงาน", type: "enum", enum: OrgRootRank, default: OrgRootRank.DEPARTMENT, }) orgRootRank: OrgRootRank; @Column({ nullable: true, comment: "ลำดับที่ของหน่วยงาน", }) orgRootOrder: number; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", }) orgRootPhoneEx: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", }) orgRootPhoneIn: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรสาร", }) orgRootFax: string; @Column({ nullable: true, comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0 default: true }) orgRootIsNormal: boolean; @Column({ length: 40, default: "00000000-0000-0000-0000-000000000000", }) orgRevisionId: string; //child table 1,2,3,4 @OneToMany(() => OrgChild1, orgChild1 => orgChild1.orgRoot) orgChild1s: OrgChild1[]; // @OneToMany(() => OrgChild2, orgChild2 => orgChild2.orgRoot) // orgChild2s: OrgChild2[]; // @OneToMany(() => OrgChild3, orgChild3 => orgChild3.orgRoot) // orgChild3s: OrgChild3[]; // @OneToMany(() => OrgChild4, orgChild4 => orgChild4.orgRoot) // orgChild4s: OrgChild4[]; } export type UpdateOrgRoot = Partial; export class CreateOrgRoot { @Column() orgRootName: string; @Column() orgRootShortName: string; @Column() orgRootCode: string; @Column() orgRootRank: OrgRootRank; @Column() orgRootOrder: number; @Column() orgRootPhoneEx: string; @Column() orgRootPhoneIn: string; @Column() orgRootFax: string; @Column() orgRootIsNormal: boolean; }