2024-01-24 16:08:34 +07:00
|
|
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
|
|
|
|
import { EntityBase } from "./base/Base";
|
|
|
|
|
import { OrgChild1 } from "./OrgChild1";
|
2024-01-26 15:54:07 +07:00
|
|
|
import { OrgRevision } from "./OrgRevision";
|
2024-01-31 14:29:39 +07:00
|
|
|
import { OrgChild2 } from "./OrgChild2";
|
|
|
|
|
import { OrgChild3 } from "./OrgChild3";
|
|
|
|
|
import { OrgChild4 } from "./OrgChild4";
|
2024-01-31 15:31:20 +07:00
|
|
|
import { PosMaster } from "./PosMaster";
|
2024-01-24 16:08:34 +07:00
|
|
|
|
|
|
|
|
// ENUM orgRootRank
|
|
|
|
|
enum OrgRootRank {
|
2024-01-26 10:13:07 +07:00
|
|
|
DEPARTMENT = "DEPARTMENT",
|
|
|
|
|
OFFICE = "OFFICE",
|
|
|
|
|
DIVISION = "DIVISION",
|
|
|
|
|
SECTION = "SECTION",
|
2024-01-24 16:08:34 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Entity("orgRoot")
|
|
|
|
|
export class OrgRoot extends EntityBase {
|
|
|
|
|
@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({
|
|
|
|
|
length: 40,
|
|
|
|
|
default: "00000000-0000-0000-0000-000000000000",
|
|
|
|
|
})
|
2024-01-26 20:25:18 +07:00
|
|
|
isAncestorDNA: string;
|
2024-01-24 16:08:34 +07:00
|
|
|
|
2024-01-26 09:56:27 +07:00
|
|
|
@Column({
|
|
|
|
|
length: 40,
|
|
|
|
|
default: "00000000-0000-0000-0000-000000000000",
|
|
|
|
|
})
|
2024-01-26 20:25:18 +07:00
|
|
|
orgRevisionId: string;
|
|
|
|
|
|
|
|
|
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots)
|
2024-01-26 15:54:07 +07:00
|
|
|
@JoinColumn({ name: "orgRevisionId" })
|
|
|
|
|
orgRevision: OrgRevision;
|
2024-01-26 20:25:18 +07:00
|
|
|
|
2024-01-31 15:31:20 +07:00
|
|
|
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRoot)
|
|
|
|
|
posMasters: PosMaster[];
|
|
|
|
|
|
2024-01-25 14:35:19 +07:00
|
|
|
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
|
2024-01-24 16:08:34 +07:00
|
|
|
orgChild1s: OrgChild1[];
|
2024-01-31 14:29:39 +07:00
|
|
|
|
|
|
|
|
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
|
|
|
|
|
orgChild2s: OrgChild2[];
|
|
|
|
|
|
|
|
|
|
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
|
|
|
|
|
orgChild3s: OrgChild3[];
|
|
|
|
|
|
|
|
|
|
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
|
|
|
|
|
orgChild4s: OrgChild4[];
|
2024-01-24 16:08:34 +07:00
|
|
|
}
|
|
|
|
|
|
2024-01-25 10:13:36 +07:00
|
|
|
export class CreateOrgRoot {
|
|
|
|
|
@Column()
|
|
|
|
|
orgRootName: string;
|
|
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
|
orgRootShortName: string;
|
|
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
|
orgRootCode: string;
|
|
|
|
|
|
|
|
|
|
@Column()
|
|
|
|
|
orgRootRank: OrgRootRank;
|
|
|
|
|
|
|
|
|
|
@Column()
|
2024-01-26 15:54:07 +07:00
|
|
|
orgRootPhoneEx?: string;
|
2024-01-25 10:13:36 +07:00
|
|
|
|
|
|
|
|
@Column()
|
2024-01-26 15:54:07 +07:00
|
|
|
orgRootPhoneIn?: string;
|
2024-01-25 10:13:36 +07:00
|
|
|
|
|
|
|
|
@Column()
|
2024-01-26 15:54:07 +07:00
|
|
|
orgRootFax?: string;
|
2024-01-25 10:13:36 +07:00
|
|
|
|
2024-01-26 20:25:18 +07:00
|
|
|
@Column("uuid")
|
|
|
|
|
orgRevisionId: string;
|
2024-01-25 10:13:36 +07:00
|
|
|
}
|
2024-01-26 15:54:07 +07:00
|
|
|
|
|
|
|
|
export type UpdateOrgRoot = Partial<CreateOrgRoot> & { orgRootRank?: OrgRootRank };
|