170 lines
4.2 KiB
TypeScript
170 lines
4.2 KiB
TypeScript
import { Entity, Column, ManyToOne, JoinColumn, OneToMany, ManyToMany } from "typeorm";
|
|
import { EntityBase } from "./base/Base";
|
|
import { OrgChild1 } from "./OrgChild1";
|
|
import { OrgRevision } from "./OrgRevision";
|
|
import { OrgChild2 } from "./OrgChild2";
|
|
import { OrgChild3 } from "./OrgChild3";
|
|
import { OrgChild4 } from "./OrgChild4";
|
|
import { PosMaster } from "./PosMaster";
|
|
import { Profile } from "./Profile";
|
|
import { PermissionOrg } from "./PermissionOrg";
|
|
|
|
enum OrgRootRank {
|
|
DEPARTMENT = "DEPARTMENT",
|
|
OFFICE = "OFFICE",
|
|
DIVISION = "DIVISION",
|
|
SECTION = "SECTION",
|
|
}
|
|
|
|
@Entity("orgRoot")
|
|
export class OrgRoot extends EntityBase {
|
|
@Column({
|
|
nullable: true,
|
|
comment: "ชื่อหน่วยงาน",
|
|
length: 255,
|
|
default: null,
|
|
})
|
|
orgRootName: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "ชื่อย่อหน่วยงาน",
|
|
length: 16,
|
|
default: null,
|
|
})
|
|
orgRootShortName: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "รหัสหน่วยงาน",
|
|
length: 8,
|
|
default: null,
|
|
})
|
|
orgRootCode: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "ระดับของหน่วยงาน",
|
|
type: "enum",
|
|
enum: OrgRootRank,
|
|
default: null,
|
|
})
|
|
orgRootRank: OrgRootRank;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "ระดับส่วนราชการsub",
|
|
default: null,
|
|
})
|
|
orgRootRankSub: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
comment: "ลำดับที่ของหน่วยงาน",
|
|
default: null,
|
|
})
|
|
orgRootOrder: number;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
length: 64,
|
|
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายนอก",
|
|
default: null,
|
|
})
|
|
orgRootPhoneEx: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
length: 64,
|
|
comment: "หมายเลขโทรศัพท์ที่ติดต่อจากภายใน",
|
|
default: null,
|
|
})
|
|
orgRootPhoneIn: string;
|
|
|
|
@Column({
|
|
nullable: true,
|
|
length: 64,
|
|
comment: "หมายเลขโทรสาร",
|
|
default: null,
|
|
})
|
|
orgRootFax: 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({
|
|
length: 40,
|
|
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
|
})
|
|
orgRevisionId: string;
|
|
|
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots)
|
|
@JoinColumn({ name: "orgRevisionId" })
|
|
orgRevision: OrgRevision;
|
|
|
|
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRoot)
|
|
posMasters: PosMaster[];
|
|
|
|
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
|
|
orgChild1s: OrgChild1[];
|
|
|
|
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
|
|
orgChild2s: OrgChild2[];
|
|
|
|
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
|
|
orgChild3s: OrgChild3[];
|
|
|
|
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
|
|
orgChild4s: OrgChild4[];
|
|
|
|
@OneToMany(() => PermissionOrg, (permissionOrg) => permissionOrg.orgRootTree)
|
|
permissionOrgRoots: PermissionOrg[];
|
|
}
|
|
|
|
export class CreateOrgRoot {
|
|
@Column()
|
|
orgRootName: string;
|
|
|
|
@Column()
|
|
orgRootShortName: string;
|
|
|
|
@Column()
|
|
orgRootCode: string;
|
|
|
|
@Column()
|
|
orgRootRank: OrgRootRank;
|
|
|
|
@Column()
|
|
orgRootRankSub?: string;
|
|
|
|
@Column()
|
|
orgRootPhoneEx?: string;
|
|
|
|
@Column()
|
|
orgRootPhoneIn?: string;
|
|
|
|
@Column()
|
|
orgRootFax?: string;
|
|
|
|
@Column()
|
|
responsibility?: string;
|
|
|
|
@Column("uuid")
|
|
orgRevisionId: string;
|
|
}
|
|
|
|
export type UpdateOrgRoot = Partial<CreateOrgRoot> & { orgRootRank?: OrgRootRank };
|