From 3e4f092c4f756d9e34989523b4a87cee1389cc4d Mon Sep 17 00:00:00 2001 From: Narul Hidayah Date: Wed, 31 Dec 2025 13:20:51 +0700 Subject: [PATCH] update --- src/entity/hrms/hrms_employee.ts | 110 +++++++++++++++++++++++++++++++ src/entity/hrms/hrms_position.ts | 8 +++ src/schema/hrms.ts | 1 + 3 files changed, 119 insertions(+) create mode 100644 src/entity/hrms/hrms_employee.ts diff --git a/src/entity/hrms/hrms_employee.ts b/src/entity/hrms/hrms_employee.ts new file mode 100644 index 0000000..7cceb91 --- /dev/null +++ b/src/entity/hrms/hrms_employee.ts @@ -0,0 +1,110 @@ +import { + Entity, + PrimaryGeneratedColumn, + Column, + CreateDateColumn, + UpdateDateColumn, + DeleteDateColumn, + ManyToOne, + JoinColumn, +} from "typeorm"; +import { Status } from "../../types/status"; +import { HrmsAirport } from "./hrms_airport"; +import { HrmsDepartment } from "./hrms_department"; +import { HrmsPosition } from "./hrms_position"; +import { HrmsShift } from "./hrms_shift"; + +@Entity("hrms_employees", { schema: "hrms" }) +export class HrmsEmployee { + + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ length: 32, unique: true }) + employee_id: string; + + @Column({ length: 32, unique: true }) + device_user_id: string; + + @Column({ length: 128 }) + name: string; + + @Column({ length: 64 }) + place_birth: string; + + @Column({ type: "date" }) + birth_date: Date; + + @Column({ length: 16 }) + gender: string; + + @Column({ length: 32 }) + phone: string; + + @Column({ length: 128 }) + email: string; + + @Column({ length: 64 }) + nationality: string; + + @Column({ length: 64 }) + last_education: string; + + @Column({ nullable: true, length: 256 }) + photo_url: string; + + @Column({ length: 64 }) + aldeia: string; + + @Column({ length: 64 }) + suco: string; + + @Column({ length: 64 }) + administrativu: string; + + @Column({ length: 64 }) + district: string; + + @Column({ length: 256 }) + street: string; + + @ManyToOne(() => HrmsAirport) + @JoinColumn({ name: "airport_id" }) + airport: HrmsAirport; + + @ManyToOne(() => HrmsDepartment) + @JoinColumn({ name: "department_id" }) + department: HrmsDepartment; + + @ManyToOne(() => HrmsPosition) + @JoinColumn({ name: "position_id" }) + position: HrmsPosition; + + @ManyToOne(() => HrmsShift) + @JoinColumn({ name: "shift_id" }) + shift: HrmsShift; + + @Column({ type: "int" }) + yearly_leave_quota: number; + + @Column({ length: 64 }) + status: Status; + + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @UpdateDateColumn({ nullable: true }) + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @DeleteDateColumn({ nullable: true }) + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/entity/hrms/hrms_position.ts b/src/entity/hrms/hrms_position.ts index 75e292d..367bc2f 100644 --- a/src/entity/hrms/hrms_position.ts +++ b/src/entity/hrms/hrms_position.ts @@ -1,5 +1,6 @@ import { Entity, PrimaryGeneratedColumn, Column, OneToMany, PrimaryColumn, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, ManyToOne, JoinColumn } from "typeorm"; import { Status } from "../../types/status"; +import { HrmsDepartment } from "./hrms_department"; @Entity("hrms_positions", { schema: "hrms" }) export class HrmsPosition { @@ -27,6 +28,13 @@ export class HrmsPosition { }) description: string; + @ManyToOne(() => HrmsDepartment, { + nullable: false, + onDelete: "RESTRICT" + }) + @JoinColumn({ name: "department_id" }) + department: HrmsDepartment; + @ManyToOne(() => HrmsPosition, position => position.children, { nullable: true, onDelete: "SET NULL" diff --git a/src/schema/hrms.ts b/src/schema/hrms.ts index 7d994c5..e9c9b60 100644 --- a/src/schema/hrms.ts +++ b/src/schema/hrms.ts @@ -4,5 +4,6 @@ export * from "../entity/hrms/hrms_position" export * from "../entity/hrms/hrms_holiday" export * from "../entity/hrms/hrms_leave_type" export * from "../entity/hrms/hrms_shift" +export * from "../entity/hrms/hrms_employee" export * from "../types/hrms" \ No newline at end of file