hrms-api-org/src/entities/OrgChild2.ts
2024-03-13 10:12:13 +07:00

166 lines
4.2 KiB
TypeScript

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";
import { OrgRevision } from "./OrgRevision";
import { PosMaster } from "./PosMaster";
enum OrgChild2Rank {
DEPARTMENT = "DEPARTMENT",
OFFICE = "OFFICE",
DIVISION = "DIVISION",
SECTION = "SECTION",
}
@Entity("orgChild2")
export class OrgChild2 extends EntityBase {
@Column({
nullable: true,
comment: "ชื่อส่วนราชการ",
length: 255,
default: null,
})
orgChild2Name: string;
@Column({
nullable: true,
comment: "ชื่อย่อส่วนราชการ",
length: 16,
default: null,
})
orgChild2ShortName: string;
@Column({
nullable: true,
comment: "รหัสส่วนราชการ",
length: 8,
default: null,
})
orgChild2Code: string;
@Column({
nullable: true,
comment: "ระดับส่วนราชการ",
type: "enum",
enum: OrgChild2Rank,
default: null,
})
orgChild2Rank: OrgChild2Rank;
@Column({
nullable: true,
comment: "ระดับส่วนราชการsub",
default: null,
})
orgChild2RankSub: string;
@Column({
nullable: true,
comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน",
default: null,
})
orgChild2Order: number;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก",
default: null,
})
orgChild2PhoneEx: string;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน",
default: null,
})
orgChild2PhoneIn: string;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรสาร",
default: null,
})
orgChild2Fax: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง orgRoot",
})
orgRootId: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง orgChild1",
})
orgChild1Id: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง orgRevision",
})
orgRevisionId: string;
@Column({
nullable: true,
length: 40,
comment:
"รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้าง โครงสร้างใหม่ที่ทำสำเนากับโครงสร้างเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขโครงสร้างย้อนหลังได้",
default: null,
})
ancestorDNA: string;
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild2s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild2s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild2s)
@JoinColumn({ name: "orgChild1Id" })
orgChild1: OrgChild1;
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild2)
orgChild3s: OrgChild3[];
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild2)
orgChild4s: OrgChild4[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild2)
posMasters: PosMaster[];
}
export class CreateOrgChild2 {
@Column()
orgChild2Name: string;
@Column()
orgChild2ShortName: string;
@Column()
orgChild2Code: string;
@Column()
orgChild2Rank: string;
@Column()
orgChild2RankSub?: string;
@Column()
orgChild2PhoneEx?: string;
@Column()
orgChild2PhoneIn?: string;
@Column()
orgChild2Fax?: string;
@Column("uuid")
orgChild1Id: string;
}
export type UpdateOrgChild2 = Partial<CreateOrgChild2> & { orgChild2Rank?: OrgChild2Rank };