hrms-api-org/src/entities/OrgChild1.ts
2025-02-20 13:29:29 +07:00

256 lines
5.7 KiB
TypeScript

import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { OrgRoot } from "./OrgRoot";
import { OrgChild2 } from "./OrgChild2";
import { OrgRevision } from "./OrgRevision";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
import { PosMaster } from "./PosMaster";
import { EmployeePosMaster } from "./EmployeePosMaster";
import { EmployeeTempPosMaster } from "./EmployeeTempPosMaster";
enum OrgChild1Rank {
DEPARTMENT = "DEPARTMENT",
OFFICE = "OFFICE",
DIVISION = "DIVISION",
SECTION = "SECTION",
}
@Entity("orgChild1")
export class OrgChild1 extends EntityBase {
@Column({
nullable: true,
comment: "MisId",
length: 255,
default: null,
})
misId: string;
@Column({
nullable: true,
comment: "ชื่อส่วนราชการ",
length: 255,
default: null,
})
orgChild1Name: string;
@Column({
nullable: true,
comment: "ชื่อย่อส่วนราชการ",
length: 16,
default: null,
})
orgChild1ShortName: string;
@Column({
nullable: true,
comment: "รหัสส่วนราชการ",
length: 8,
default: null,
})
orgChild1Code: string;
@Column({
nullable: true,
comment: "ระดับส่วนราชการ",
type: "enum",
enum: OrgChild1Rank,
default: null,
})
orgChild1Rank: OrgChild1Rank;
@Column({
nullable: true,
comment: "ระดับส่วนราชการsub",
default: null,
})
orgChild1RankSub: string;
@Column({
nullable: true,
comment: "ลำดับที่ของส่วนราชการภายใน Child เดียวกัน",
default: null,
})
orgChild1Order: number;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก",
default: null,
})
orgChild1PhoneEx: string;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน",
default: null,
})
orgChild1PhoneIn: string;
@Column({
nullable: true,
length: 64,
comment: "หมายเลขโทรสาร",
default: null,
})
orgChild1Fax: string;
@Column({
length: 40,
comment: "คีย์นอก(FK)ของตาราง orgRoot",
})
orgRootId: 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;
@Column({
comment: "เป็นสกจ",
default: false,
})
isOfficer: boolean;
@Column({
comment: "ศูนย์สารสนเทศทรัพยากรบุคคล",
default: false,
})
isInformation: boolean;
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
@JoinColumn({ name: "orgRevisionId" })
orgRevision: OrgRevision;
@Column({
nullable: true,
length: 5,
comment: "DEPARTMENT_CODE",
default: null,
})
DEPARTMENT_CODE: string;
@Column({
nullable: true,
length: 5,
comment: "DIVISION_CODE",
default: null,
})
DIVISION_CODE: string;
@Column({
nullable: true,
length: 5,
comment: "SECTION_CODE",
default: null,
})
SECTION_CODE: string;
@Column({
nullable: true,
length: 5,
comment: "JOB_CODE",
default: null,
})
JOB_CODE: string;
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild1s)
@JoinColumn({ name: "orgRootId" })
orgRoot: OrgRoot;
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
orgChild2s: OrgChild2[];
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
orgChild3s: OrgChild3[];
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
orgChild4s: OrgChild4[];
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgChild1)
posMasters: PosMaster[];
@OneToMany(() => EmployeePosMaster, (employeePosMaster) => employeePosMaster.orgChild1)
employeePosMasters: EmployeePosMaster[];
@OneToMany(
() => EmployeeTempPosMaster,
(employeeTempposMaster) => employeeTempposMaster.orgChild1,
)
employeeTempPosMasters: EmployeeTempPosMaster[];
}
export class CreateOrgChild1 {
@Column()
orgChild1Name: string;
@Column()
orgChild1ShortName: string;
@Column()
orgChild1Code?: string;
@Column()
orgChild1Rank: string;
@Column()
orgChild1RankSub?: string;
@Column()
DEPARTMENT_CODE?: string;
@Column()
DIVISION_CODE?: string;
@Column()
SECTION_CODE?: string;
@Column()
JOB_CODE?: string;
@Column()
orgChild1PhoneEx?: string;
@Column()
orgChild1PhoneIn?: string;
@Column()
orgChild1Fax?: string;
@Column("uuid")
orgRootId: string;
@Column()
responsibility?: string;
@Column()
isOfficer: boolean;
@Column()
isInformation: boolean;
@Column()
misId?: string;
}
export type UpdateOrgChild1 = Partial<CreateOrgChild1> & { orgChild1Rank?: OrgChild1Rank };