diff --git a/src/entities/ProfileAbility.ts b/src/entities/ProfileAbility.ts index dfdc7206..c170fb39 100644 --- a/src/entities/ProfileAbility.ts +++ b/src/entities/ProfileAbility.ts @@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; import { ProfileAbilityHistory } from "./ProfileAbilityHistory"; +import { ProfileEmployee } from "./ProfileEmployee"; @Entity("profileAbility") export class ProfileAbility extends EntityBase { @@ -61,6 +62,14 @@ export class ProfileAbility extends EntityBase { }) field: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @OneToMany( () => ProfileAbilityHistory, (profileAbilityHistory) => profileAbilityHistory.histories, @@ -70,6 +79,10 @@ export class ProfileAbility extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileAbilities) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileAbilities) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileAbility { diff --git a/src/entities/ProfileChangeName.ts b/src/entities/ProfileChangeName.ts index cfd9cf16..84605afe 100644 --- a/src/entities/ProfileChangeName.ts +++ b/src/entities/ProfileChangeName.ts @@ -2,6 +2,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; import { ProfileChangeNameHistory } from "./ProfileChangeNameHistory"; +import { ProfileEmployee } from "./ProfileEmployee"; // import { ProfileChangeNameHistory } from "./ProfileChangeNameHistory"; @Entity("profileChangeName") @@ -62,15 +63,23 @@ export class ProfileChangeName extends EntityBase { }) documentId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @OneToMany( () => ProfileChangeNameHistory, (profileChangeNameHistory) => profileChangeNameHistory.histories, ) profileChangeNameHistories: ProfileChangeNameHistory[]; - // @ManyToOne(() => Profile, (profile) => profile.profileChangeName) - // @JoinColumn({ name: "profileId" }) - // profile: Profile; + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileChangeNames) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileChangeName { diff --git a/src/entities/ProfileEducation.ts b/src/entities/ProfileEducation.ts index e9de1d25..153c85b4 100644 --- a/src/entities/ProfileEducation.ts +++ b/src/entities/ProfileEducation.ts @@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; import { ProfileEducationHistory } from "./ProfileEducationHistory"; +import { ProfileEmployee } from "./ProfileEmployee"; @Entity("profileEducation") export class ProfileEducation extends EntityBase { @@ -159,6 +160,14 @@ export class ProfileEducation extends EntityBase { }) isEducation: boolean; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @OneToMany( () => ProfileEducationHistory, (profileEducationHistory) => profileEducationHistory.histories, @@ -168,6 +177,10 @@ export class ProfileEducation extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileEducations) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileEducations) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileEducation { diff --git a/src/entities/ProfileEmployee.ts b/src/entities/ProfileEmployee.ts index 60a3a35e..614828f7 100644 --- a/src/entities/ProfileEmployee.ts +++ b/src/entities/ProfileEmployee.ts @@ -14,6 +14,10 @@ import { ProfileLeave } from "./ProfileLeave"; import { ProfileDuty } from "./ProfileDuty"; import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileDiscipline } from "./ProfileDiscipline"; +import { ProfileChangeName } from "./ProfileChangeName"; +import { ProfileFamilyHistory } from "./ProfileFamily"; +import { ProfileEducation } from "./ProfileEducation"; +import { ProfileAbility } from "./ProfileAbility"; @Entity("profileEmployee") export class ProfileEmployee extends EntityBase { @Column({ @@ -232,6 +236,18 @@ export class ProfileEmployee extends EntityBase { @OneToMany(() => ProfileDiscipline, (v) => v.profileEmployee) profileDisciplines: ProfileNopaid[]; + @OneToMany(() => ProfileChangeName, (v) => v.profileEmployee) + profileChangeNames: ProfileChangeName[]; + + @OneToMany(() => ProfileFamilyHistory, (v) => v.profileEmployee) + profileFamilys: ProfileFamilyHistory[]; + + @OneToMany(() => ProfileEducation, (v) => v.profileEmployee) + profileEducations: ProfileEducation[]; + + @OneToMany(() => ProfileAbility, (v) => v.profileEmployee) + profileAbilities: ProfileAbility[]; + @ManyToOne(() => EmployeePosLevel, (v) => v.profiles) posLevel: EmployeePosLevel; @@ -275,6 +291,8 @@ export class CreateProfileEmployee { gender: string | null; relationship: string | null; bloodGroup: string | null; + email: string | null ; + phone: string | null; } export type UpdateProfileEmployee = { @@ -296,4 +314,6 @@ export type UpdateProfileEmployee = { gender?: string | null; relationship?: string | null; bloodGroup?: string | null; + email: string | null; + phone: string | null; }; diff --git a/src/entities/ProfileFamily.ts b/src/entities/ProfileFamily.ts index 0a25b040..3503eea7 100644 --- a/src/entities/ProfileFamily.ts +++ b/src/entities/ProfileFamily.ts @@ -1,6 +1,7 @@ -import { Column, Entity, ManyToOne, OneToMany } from "typeorm"; +import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; @Entity("profileFamilyHistory") export class ProfileFamilyHistory extends EntityBase { @@ -155,11 +156,23 @@ export class ProfileFamilyHistory extends EntityBase { }) profileId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @ManyToOne(() => Profile, (v) => v.profileFamily) profile: Profile; @OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory) profileChildrenHistories: ProfileChildrenHistory[]; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } @Entity("profileChildren")