hrms-api-org/src/entities/OrgRoot.ts

145 lines
3.1 KiB
TypeScript
Raw Normal View History

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";
import { OrgChild2 } from "./OrgChild2";
import { OrgChild3 } from "./OrgChild3";
import { OrgChild4 } from "./OrgChild4";
// ENUM orgRootRank
enum OrgRootRank {
DEPARTMENT = "department",
OFFICE = "office",
DIVISION = "division",
SECTION = "section",
}
@Entity("orgRoot")
export class OrgRoot extends EntityBase {
// @Column({
// comment: "",
// length: 40,
// default: "00000000-0000-0000-0000-000000000000",
// })
// orgRootId: string;
@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({
nullable: true,
comment: "สถานะของหน่วยงาน", //ปกติ = 1 , ยุกเลิก = 0
2024-01-25 10:13:36 +07:00
default: true
2024-01-24 16:08:34 +07:00
})
2024-01-25 10:13:36 +07:00
orgRootIsNormal: boolean;
2024-01-24 16:08:34 +07:00
@Column({
length: 40,
default: "00000000-0000-0000-0000-000000000000",
})
2024-01-25 10:13:36 +07:00
orgRevisionId: string;
2024-01-24 16:08:34 +07:00
//child table 1,2,3,4
@OneToMany(() => OrgChild1, orgChild1 => orgChild1.orgRoot)
orgChild1s: OrgChild1[];
2024-01-24 17:22:41 +07:00
// @OneToMany(() => OrgChild2, orgChild2 => orgChild2.orgRoot)
// orgChild2s: OrgChild2[];
2024-01-24 16:08:34 +07:00
2024-01-24 17:22:41 +07:00
// @OneToMany(() => OrgChild3, orgChild3 => orgChild3.orgRoot)
// orgChild3s: OrgChild3[];
2024-01-24 16:08:34 +07:00
2024-01-24 17:22:41 +07:00
// @OneToMany(() => OrgChild4, orgChild4 => orgChild4.orgRoot)
// orgChild4s: OrgChild4[];
2024-01-24 16:08:34 +07:00
}
export type UpdateOrgRoot = Partial<OrgRoot>;
2024-01-25 10:13:36 +07:00
export class CreateOrgRoot {
@Column()
orgRootName: string;
@Column()
orgRootShortName: string;
@Column()
orgRootCode: string;
@Column()
orgRootRank: OrgRootRank;
@Column()
orgRootOrder: number;
@Column()
orgRootPhoneEx: string;
@Column()
orgRootPhoneIn: string;
@Column()
orgRootFax: string;
@Column()
orgRootIsNormal: boolean;
}