diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index c2f7fe44..f8218989 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -21,6 +21,7 @@ import { ProfileGovernment } from "./ProfileGovernment"; import { Gender } from "./Gender"; import { Relationship } from "./Relationship"; import { BloodGroup } from "./BloodGroup"; +import { Religion } from "./Religion"; @Entity("profile") export class Profile extends EntityBase { @@ -149,14 +150,6 @@ export class Profile extends EntityBase { }) ethnicity: string; - @Column({ - nullable: true, - comment: "ศาสนา", - length: 255, - default: null, - }) - religion: string; - @Column({ nullable: true, comment: "เบอร์โทร", @@ -187,6 +180,17 @@ export class Profile extends EntityBase { @ManyToOne(() => Relationship, (v) => v.profile) relationship: Relationship; + @Column({ + nullable: true, + comment: "ศาสนา", + length: 255, + default: null, + }) + religionId: string; + + @ManyToOne(() => Religion, (v) => v.profile) + religion: Religion; + @Column({ nullable: true, comment: "กรุ๊ปเลือด", @@ -286,9 +290,9 @@ export class CreateProfile { dateRetire: Date | null; birthDate: Date | null; ethnicity: string | null; - religion: string | null; telephoneNumber: string | null; citizenId: string; + religionId: string | null; posLevelId: string | null; posTypeId: string | null; genderId: string | null; @@ -308,9 +312,9 @@ export type UpdateProfile = { dateRetire?: Date | null; birthDate?: Date | null; ethnicity?: string | null; - religion?: string | null; telephoneNumber?: string | null; citizenId?: string | null; + religionId: string | null; posLevelId?: string | null; posTypeId?: string | null; genderId?: string | null; diff --git a/src/entities/ProfileEmployee.ts b/src/entities/ProfileEmployee.ts index 1dd89307..740237a3 100644 --- a/src/entities/ProfileEmployee.ts +++ b/src/entities/ProfileEmployee.ts @@ -8,6 +8,7 @@ import { ProfileDisciplineEmployee } from "./ProfileDisciplineEmployee"; import { BloodGroup } from "./BloodGroup"; import { Relationship } from "./Relationship"; import { Gender } from "./Gender"; +import { Religion } from "./Religion"; @Entity("profileEmployee") export class ProfileEmployee extends EntityBase { @@ -125,14 +126,6 @@ export class ProfileEmployee extends EntityBase { }) ethnicity: string; - @Column({ - nullable: true, - comment: "ศาสนา", - length: 255, - default: null, - }) - religion: string; - @Column({ nullable: true, comment: "เบอร์โทร", @@ -163,6 +156,17 @@ export class ProfileEmployee extends EntityBase { @ManyToOne(() => Relationship, (v) => v.profileEmployee) relationship: Relationship; + @Column({ + nullable: true, + comment: "ศาสนา", + length: 255, + default: null, + }) + religionId: string; + + @ManyToOne(() => Religion, (v) => v.profile) + religion: Religion; + @Column({ nullable: true, comment: "กรุ๊ปเลือด", @@ -220,9 +224,9 @@ export class CreateProfileEmployee { birthDate: Date | null; salaryLevel: number | null; ethnicity: string | null; - religion: string | null; telephoneNumber: string | null; citizenId: string; + religionId: string | null; posLevelId: string | null; posTypeId: string | null; genderId: string | null; @@ -240,9 +244,9 @@ export type UpdateProfileEmployee = { birthDate?: Date | null; salaryLevel?: number | null; ethnicity?: string | null; - religion?: string | null; telephoneNumber?: string | null; citizenId?: string; + religionId: string | null; posLevelId?: string | null; posTypeId?: string | null; genderId?: string | null; diff --git a/src/entities/Religion.ts b/src/entities/Religion.ts index 04840bf4..55d393d4 100644 --- a/src/entities/Religion.ts +++ b/src/entities/Religion.ts @@ -1,5 +1,7 @@ -import { Entity, Column} from "typeorm"; +import { Entity, Column, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; +import { ProfileEmployee } from "./ProfileEmployee"; @Entity("religion") export class Religion extends EntityBase { @@ -10,6 +12,12 @@ export class Religion extends EntityBase { default: null, }) name: string; + + @OneToMany(() => Profile, (v) => v.religion) + profile: Profile[]; + + @OneToMany(() => ProfileEmployee, (v) => v.religion) + profileEmployee: ProfileEmployee[]; } export class CreateReligion {