From 2b24e4352276924c498b945786af9b03bb18bdf6 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 21 Mar 2024 13:27:00 +0700 Subject: [PATCH] fix: profile leave entity --- src/entities/ProfileLeave.ts | 19 ++++++++++++++--- src/entities/ProfileLeaveHistory.ts | 33 ----------------------------- 2 files changed, 16 insertions(+), 36 deletions(-) delete mode 100644 src/entities/ProfileLeaveHistory.ts diff --git a/src/entities/ProfileLeave.ts b/src/entities/ProfileLeave.ts index 89636da0..6192f3e8 100644 --- a/src/entities/ProfileLeave.ts +++ b/src/entities/ProfileLeave.ts @@ -1,7 +1,6 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; -import { ProfileLeaveHistory } from "./ProfileLeaveHistory"; import { LeaveType } from "./LeaveType"; @Entity("profileLeave") @@ -70,8 +69,8 @@ export class ProfileLeave extends EntityBase { }) reason: string; - @OneToMany(() => ProfileLeaveHistory, (v) => v.histories) - profileLeaves: ProfileLeaveHistory[]; + @OneToMany(() => ProfileLeaveHistory, (v) => v.profileLeave) + histories: ProfileLeaveHistory[]; @ManyToOne(() => LeaveType, (v) => v.profileLeave) leaveType: LeaveType; @@ -80,6 +79,20 @@ export class ProfileLeave extends EntityBase { profile: Profile; } +@Entity("profileLeaveHistory") +export class ProfileLeaveHistory extends ProfileLeave { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileLeave", + default: null, + }) + profileLeaveId: string; + + @ManyToOne(() => ProfileLeave, (v) => v.histories) + profileLeave: ProfileLeave; +} + export class CreateProfileLeave { profileId: string | null; leaveTypeId: string | null; diff --git a/src/entities/ProfileLeaveHistory.ts b/src/entities/ProfileLeaveHistory.ts deleted file mode 100644 index 1e43b4bd..00000000 --- a/src/entities/ProfileLeaveHistory.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; -import { EntityBase } from "./base/Base"; -import { Profile } from "./Profile"; -import { ProfileLeave, CreateProfileLeave, UpdateProfileLeave } from "./ProfileLeave"; - -@Entity("profileLeaveHistory") -export class ProfileLeaveHistory extends ProfileLeave { - @Column({ - nullable: true, - length: 40, - comment: "คีย์นอก(FK)ของตาราง ProfileLeave", - default: null, - }) - profileLeaveId: string; - - @ManyToOne(() => ProfileLeave, (profileLeave) => profileLeave.profileLeaves) - @JoinColumn({ name: "profileLeaveId" }) - histories: ProfileLeave; -} - -export class CreateProfileLeaveHistory extends CreateProfileLeave { - profileLeaveId: string | null; -} - -export type UpdateProfileLeaveHistory = { - leaveTypeId?: string | null; - dateLeave?: Date | null; - leaveDays?: number | null; - leverCount?: number | null; - totalLeave?: number | null; - status?: string | null; - reason?: string | null; -};