import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { OrgRoot } from "./OrgRoot"; import { OrgChild1 } from "./OrgChild1"; import { OrgChild3 } from "./OrgChild3"; import { OrgChild4 } from "./OrgChild4"; // ENUM orgChild2Rank enum OrgChild2Rank { DEPARTMENT = "department", OFFICE = "office", DIVISION = "division", SECTION = "section", } @Entity("orgChild2") export class OrgChild2 extends EntityBase { // @Column({ // comment: "", // length: 40, // default: "00000000-0000-0000-0000-000000000000", // }) // orgChild2Id: string; @Column({ nullable: true, comment: "ชื่อส่วนราชการ", length: 255, default: "string", }) orgChild2Name: string; @Column({ nullable: true, comment: "ชื่อย่อส่วนราชการ", length: 16, default: "string", }) orgChild2ShortName: string; @Column({ nullable: true, comment: "รหัสส่วนราชการ", length: 8, default: "string", }) orgChild2Code: string; @Column({ nullable: true, comment: "ระดับส่วนราชการ", type: "enum", enum: OrgChild2Rank, // default: OrgChild2Rank.DEPARTMENT, }) orgChild2Rank: OrgChild2Rank; @Column({ nullable: true, comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน", }) orgChild2Order: number; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก", }) orgChild2PhoneEx: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน", }) orgChild2PhoneIn: string; @Column({ nullable: true, length: 64, comment: "หมายเลขโทรสาร", }) orgChild2Fax: string; @Column({ nullable: true, comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0 default: true }) orgChild2IsNormal: boolean; @Column({ length: 40, default: "00000000-0000-0000-0000-000000000000", }) orgRootId: string; @Column({ length: 40, default: "00000000-0000-0000-0000-000000000000", }) orgChild1Id: string; @ManyToOne(() => OrgChild1, orgChild1 => orgChild1.orgChild2s) @JoinColumn({ name: "orgChild1Id" }) orgChild1: OrgChild1; @OneToMany(() => OrgChild3, orgChild3 => orgChild3.orgChild2) orgChild3s: OrgChild3[]; } export class CreateOrgChild2 { @Column() orgChild2Name: string; @Column() orgChild2ShortName: string; @Column() orgChild2Code: string; @Column() orgChild2Rank: string; @Column() orgChild2Order: number; @Column() orgChild2PhoneEx: string; @Column() orgChild2PhoneIn: string; @Column() orgChild2Fax: string; @Column() orgChild2IsNormal: boolean; @Column('uuid') orgRootId: string; @Column('uuid') orgChild1Id: string; } export type UpdateOrgChild2 = Partial;