relation profileEmployee

This commit is contained in:
AnandaTon 2024-05-13 16:37:51 +07:00
parent 9a7adc4eb5
commit b1c6f5fead
5 changed files with 76 additions and 7 deletions

View file

@ -1,6 +1,7 @@
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
import { LeaveType } from "./LeaveType";
@Entity("profileLeave")
@ -13,6 +14,14 @@ export class ProfileLeave extends EntityBase {
})
profileId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@Column({
nullable: true,
length: 40,
@ -85,6 +94,10 @@ export class ProfileLeave extends EntityBase {
@ManyToOne(() => Profile, (v) => v.profileLeaves)
profile: Profile;
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileLeaves)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
@Entity("profileLeaveHistory")
@ -102,8 +115,9 @@ export class ProfileLeaveHistory extends ProfileLeave {
}
export class CreateProfileLeave {
profileId: string | null;
profileId?: string | null;
leaveTypeId: string;
profileEmployeeId?: string | null;
dateLeaveStart: Date | null;
dateLeaveEnd: Date | null;
leaveDays: number | null;