From 59607aafd1e72e1645a4d797dd7e23a89addd445 Mon Sep 17 00:00:00 2001 From: Bright Date: Mon, 13 May 2024 15:06:52 +0700 Subject: [PATCH] relation profileEmployee --- src/entities/ProfileAssessment.ts | 13 +++++++++++++ src/entities/ProfileCertificate.ts | 13 +++++++++++++ src/entities/ProfileEmployee.ts | 21 ++++++++++++++++++++- src/entities/ProfileHonor.ts | 13 +++++++++++++ src/entities/ProfileInsignia.ts | 13 +++++++++++++ src/entities/ProfileTraining.ts | 13 +++++++++++++ 6 files changed, 85 insertions(+), 1 deletion(-) diff --git a/src/entities/ProfileAssessment.ts b/src/entities/ProfileAssessment.ts index 2a3a99c9..3ecc0c8f 100644 --- a/src/entities/ProfileAssessment.ts +++ b/src/entities/ProfileAssessment.ts @@ -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 { ProfileAssessmentHistory } from "./ProfileAssessmentHistory"; @Entity("profileAssessment") @@ -13,6 +14,14 @@ export class ProfileAssessment extends EntityBase { }) profileId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @Column({ nullable: true, comment: "ชื่อแบบประเมิน", @@ -86,6 +95,10 @@ export class ProfileAssessment extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileAssessments) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileAssessments) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileAssessment { diff --git a/src/entities/ProfileCertificate.ts b/src/entities/ProfileCertificate.ts index 6efbceac..745e1568 100644 --- a/src/entities/ProfileCertificate.ts +++ b/src/entities/ProfileCertificate.ts @@ -1,6 +1,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; import { ProfileCertificateHistory } from "./ProfileCertificateHistory"; @Entity("profileCertificate") @@ -13,6 +14,14 @@ export class ProfileCertificate extends EntityBase { }) profileId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @Column({ nullable: true, type: "datetime", @@ -62,6 +71,10 @@ export class ProfileCertificate extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileCertificates) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileCertificates) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileCertificate { diff --git a/src/entities/ProfileEmployee.ts b/src/entities/ProfileEmployee.ts index c971be08..5ba248f8 100644 --- a/src/entities/ProfileEmployee.ts +++ b/src/entities/ProfileEmployee.ts @@ -5,7 +5,11 @@ import { EmployeePosType } from "./EmployeePosType"; import { EmployeePosMaster } from "./EmployeePosMaster"; import { ProfileSalaryEmployee } from "./ProfileSalaryEmployee"; import { ProfileDisciplineEmployee } from "./ProfileDisciplineEmployee"; - +import { ProfileCertificate } from "./ProfileCertificate"; +import { ProfileTraining } from "./ProfileTraining"; +import { ProfileInsignia } from "./ProfileInsignia"; +import { ProfileHonor } from "./ProfileHonor"; +import { ProfileAssessment } from "./ProfileAssessment"; @Entity("profileEmployee") export class ProfileEmployee extends EntityBase { @Column({ @@ -197,6 +201,21 @@ export class ProfileEmployee extends EntityBase { @OneToMany(() => ProfileDisciplineEmployee, (v) => v.profile) profileDiscipline: ProfileDisciplineEmployee[]; + @OneToMany(() => ProfileCertificate, (v) => v.profileEmployee) + profileCertificates: ProfileCertificate[]; + + @OneToMany(() => ProfileTraining, (v) => v.profileEmployee) + profileTrainings: ProfileTraining[]; + + @OneToMany(() => ProfileInsignia, (v) => v.profileEmployee) + profileInsignias: ProfileInsignia[]; + + @OneToMany(() => ProfileHonor, (v) => v.profileEmployee) + profileHonors: ProfileHonor[]; + + @OneToMany(() => ProfileAssessment, (v) => v.profileEmployee) + profileAssessments: ProfileAssessment[]; + @ManyToOne(() => EmployeePosLevel, (v) => v.profiles) posLevel: EmployeePosLevel; diff --git a/src/entities/ProfileHonor.ts b/src/entities/ProfileHonor.ts index fc092a96..04f3032b 100644 --- a/src/entities/ProfileHonor.ts +++ b/src/entities/ProfileHonor.ts @@ -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 { ProfileHonorHistory } from "./ProfileHonorHistory"; @Entity("profileHonor") @@ -13,6 +14,14 @@ export class ProfileHonor extends EntityBase { }) profileId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @Column({ nullable: true, length: 2000, @@ -66,6 +75,10 @@ export class ProfileHonor extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileHonors) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileHonors) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileHonor { diff --git a/src/entities/ProfileInsignia.ts b/src/entities/ProfileInsignia.ts index ee178e33..d5311195 100644 --- a/src/entities/ProfileInsignia.ts +++ b/src/entities/ProfileInsignia.ts @@ -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 { ProfileInsigniaHistory } from "./ProfileInsigniaHistory"; import { Insignia } from "./Insignia"; @@ -14,6 +15,14 @@ export class ProfileInsignia extends EntityBase { }) profileId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @Column({ comment: "ปีที่ยื่นขอ", }) @@ -126,6 +135,10 @@ export class ProfileInsignia extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileInsignias) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileInsignias) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileInsignia { diff --git a/src/entities/ProfileTraining.ts b/src/entities/ProfileTraining.ts index c6295865..58694066 100644 --- a/src/entities/ProfileTraining.ts +++ b/src/entities/ProfileTraining.ts @@ -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 { ProfileTrainingHistory } from "./ProfileTrainingHistory"; @Entity("profileTraining") @@ -13,6 +14,14 @@ export class ProfileTraining extends EntityBase { }) profileId: string; + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", + default: null, + }) + profileEmployeeId: string; + @Column({ nullable: true, type: "datetime", @@ -108,6 +117,10 @@ export class ProfileTraining extends EntityBase { @ManyToOne(() => Profile, (profile) => profile.profileTrainings) @JoinColumn({ name: "profileId" }) profile: Profile; + + @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileTrainings) + @JoinColumn({ name: "profileEmployeeId" }) + profileEmployee: ProfileEmployee; } export class CreateProfileTraining {