fix and relation emp

This commit is contained in:
AdisakKanthawilang 2024-05-13 17:21:19 +07:00
parent 497db161c4
commit c441df3dc9
5 changed files with 72 additions and 4 deletions

View file

@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { Profile } from "./Profile"; import { Profile } from "./Profile";
import { ProfileAbilityHistory } from "./ProfileAbilityHistory"; import { ProfileAbilityHistory } from "./ProfileAbilityHistory";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("profileAbility") @Entity("profileAbility")
export class ProfileAbility extends EntityBase { export class ProfileAbility extends EntityBase {
@ -61,6 +62,14 @@ export class ProfileAbility extends EntityBase {
}) })
field: string; field: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@OneToMany( @OneToMany(
() => ProfileAbilityHistory, () => ProfileAbilityHistory,
(profileAbilityHistory) => profileAbilityHistory.histories, (profileAbilityHistory) => profileAbilityHistory.histories,
@ -70,6 +79,10 @@ export class ProfileAbility extends EntityBase {
@ManyToOne(() => Profile, (profile) => profile.profileAbilities) @ManyToOne(() => Profile, (profile) => profile.profileAbilities)
@JoinColumn({ name: "profileId" }) @JoinColumn({ name: "profileId" })
profile: Profile; profile: Profile;
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileAbilities)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
} }
export class CreateProfileAbility { export class CreateProfileAbility {

View file

@ -2,6 +2,7 @@ import { Entity, Column, OneToMany, ManyToOne, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { Profile } from "./Profile"; import { Profile } from "./Profile";
import { ProfileChangeNameHistory } from "./ProfileChangeNameHistory"; import { ProfileChangeNameHistory } from "./ProfileChangeNameHistory";
import { ProfileEmployee } from "./ProfileEmployee";
// import { ProfileChangeNameHistory } from "./ProfileChangeNameHistory"; // import { ProfileChangeNameHistory } from "./ProfileChangeNameHistory";
@Entity("profileChangeName") @Entity("profileChangeName")
@ -62,15 +63,23 @@ export class ProfileChangeName extends EntityBase {
}) })
documentId: string; documentId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@OneToMany( @OneToMany(
() => ProfileChangeNameHistory, () => ProfileChangeNameHistory,
(profileChangeNameHistory) => profileChangeNameHistory.histories, (profileChangeNameHistory) => profileChangeNameHistory.histories,
) )
profileChangeNameHistories: ProfileChangeNameHistory[]; profileChangeNameHistories: ProfileChangeNameHistory[];
// @ManyToOne(() => Profile, (profile) => profile.profileChangeName) @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileChangeNames)
// @JoinColumn({ name: "profileId" }) @JoinColumn({ name: "profileEmployeeId" })
// profile: Profile; profileEmployee: ProfileEmployee;
} }
export class CreateProfileChangeName { export class CreateProfileChangeName {

View file

@ -2,6 +2,7 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { Profile } from "./Profile"; import { Profile } from "./Profile";
import { ProfileEducationHistory } from "./ProfileEducationHistory"; import { ProfileEducationHistory } from "./ProfileEducationHistory";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("profileEducation") @Entity("profileEducation")
export class ProfileEducation extends EntityBase { export class ProfileEducation extends EntityBase {
@ -159,6 +160,14 @@ export class ProfileEducation extends EntityBase {
}) })
isEducation: boolean; isEducation: boolean;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@OneToMany( @OneToMany(
() => ProfileEducationHistory, () => ProfileEducationHistory,
(profileEducationHistory) => profileEducationHistory.histories, (profileEducationHistory) => profileEducationHistory.histories,
@ -168,6 +177,10 @@ export class ProfileEducation extends EntityBase {
@ManyToOne(() => Profile, (profile) => profile.profileEducations) @ManyToOne(() => Profile, (profile) => profile.profileEducations)
@JoinColumn({ name: "profileId" }) @JoinColumn({ name: "profileId" })
profile: Profile; profile: Profile;
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileEducations)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
} }
export class CreateProfileEducation { export class CreateProfileEducation {

View file

@ -14,6 +14,10 @@ import { ProfileLeave } from "./ProfileLeave";
import { ProfileDuty } from "./ProfileDuty"; import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileDiscipline } from "./ProfileDiscipline";
import { ProfileChangeName } from "./ProfileChangeName";
import { ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileEducation } from "./ProfileEducation";
import { ProfileAbility } from "./ProfileAbility";
@Entity("profileEmployee") @Entity("profileEmployee")
export class ProfileEmployee extends EntityBase { export class ProfileEmployee extends EntityBase {
@Column({ @Column({
@ -232,6 +236,18 @@ export class ProfileEmployee extends EntityBase {
@OneToMany(() => ProfileDiscipline, (v) => v.profileEmployee) @OneToMany(() => ProfileDiscipline, (v) => v.profileEmployee)
profileDisciplines: ProfileNopaid[]; 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) @ManyToOne(() => EmployeePosLevel, (v) => v.profiles)
posLevel: EmployeePosLevel; posLevel: EmployeePosLevel;
@ -275,6 +291,8 @@ export class CreateProfileEmployee {
gender: string | null; gender: string | null;
relationship: string | null; relationship: string | null;
bloodGroup: string | null; bloodGroup: string | null;
email: string | null ;
phone: string | null;
} }
export type UpdateProfileEmployee = { export type UpdateProfileEmployee = {
@ -296,4 +314,6 @@ export type UpdateProfileEmployee = {
gender?: string | null; gender?: string | null;
relationship?: string | null; relationship?: string | null;
bloodGroup?: string | null; bloodGroup?: string | null;
email: string | null;
phone: string | null;
}; };

View file

@ -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 { EntityBase } from "./base/Base";
import { Profile } from "./Profile"; import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("profileFamilyHistory") @Entity("profileFamilyHistory")
export class ProfileFamilyHistory extends EntityBase { export class ProfileFamilyHistory extends EntityBase {
@ -155,11 +156,23 @@ export class ProfileFamilyHistory extends EntityBase {
}) })
profileId: string; profileId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@ManyToOne(() => Profile, (v) => v.profileFamily) @ManyToOne(() => Profile, (v) => v.profileFamily)
profile: Profile; profile: Profile;
@OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory) @OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory)
profileChildrenHistories: ProfileChildrenHistory[]; profileChildrenHistories: ProfileChildrenHistory[];
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
} }
@Entity("profileChildren") @Entity("profileChildren")