hrms-api-org/src/entities/OrgChild3.ts
2024-05-14 15:29:05 +07:00

186 lines
4.6 KiB
TypeScript

import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild4 } from "./OrgChild4";
import { OrgRevision } from "./OrgRevision";
import { OrgChild1 } from "./OrgChild1";
import { OrgRoot } from "./OrgRoot";
import { PosMaster } from "./PosMaster";
enum OrgChild3Rank {
DEPARTMENT = "DEPARTMENT",
OFFICE = "OFFICE",
DIVISION = "DIVISION",
SECTION = "SECTION",
}
@Entity("orgChild3")
export class OrgChild3 extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อส่วนราชการ",
length: 255,
default: null,
})
orgChild3Name: string;
@Column({
nullable: true,
comment: "ชื่อย่อส่วนราชการ",
length: 16,
default: null,
})
orgChild3ShortName: string;
@Column({
nullable: true,
comment: "รหัสส่วนราชการ",
length: 8,
default: null,
})
orgChild3Code: string;
@Column({
nullable: true,
comment: "ระดับส่วนราชการ",
type: "enum",
enum: OrgChild3Rank,
default: null,
})
orgChild3Rank: OrgChild3Rank;
@Column({
nullable: true,
comment: "ระดับส่วนราชการsub",
default: null,
})
orgChild3RankSub: string;
@Column({
nullable: true,
comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน",
default: null,
})
orgChild3Order: number;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก",
default: null,
})
orgChild3PhoneEx: string;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน",
default: null,
})
orgChild3PhoneIn: string;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรสาร",
default: null,
})
orgChild3Fax: 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)ของตาราง 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.orgChild3s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild3s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild3s)
@JoinColumn({ name: "orgChild1Id" })
orgChild1: OrgChild1;
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild3s)
@JoinColumn({ name: "orgChild2Id" })
orgChild2: OrgChild2;
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild3)
orgChild4s: OrgChild4[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild3)
posMasters: PosMaster[];
}
export class CreateOrgChild3 {
@Column()
orgChild3Name: string;
@Column()
orgChild3ShortName: string;
@Column()
orgChild3Code: string;
@Column()
orgChild3Rank: string;
@Column()
orgChild3RankSub?: string;
@Column()
orgChild3PhoneEx?: string;
@Column()
orgChild3PhoneIn?: string;
@Column()
orgChild3Fax?: string;
@Column("uuid")
orgChild2Id: string;
@Column()
responsibility?: string;
}
export type UpdateOrgChild3 = Partial<CreateOrgChild3> & { orgChild3Rank?: OrgChild3Rank };