fix: religion relation

This commit is contained in:
Methapon2001 2024-03-21 16:29:51 +07:00
parent c32883f2e8
commit 02878b769b
3 changed files with 37 additions and 21 deletions

View file

@ -21,6 +21,7 @@ import { ProfileGovernment } from "./ProfileGovernment";
import { Gender } from "./Gender"; import { Gender } from "./Gender";
import { Relationship } from "./Relationship"; import { Relationship } from "./Relationship";
import { BloodGroup } from "./BloodGroup"; import { BloodGroup } from "./BloodGroup";
import { Religion } from "./Religion";
@Entity("profile") @Entity("profile")
export class Profile extends EntityBase { export class Profile extends EntityBase {
@ -149,14 +150,6 @@ export class Profile extends EntityBase {
}) })
ethnicity: string; ethnicity: string;
@Column({
nullable: true,
comment: "ศาสนา",
length: 255,
default: null,
})
religion: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เบอร์โทร", comment: "เบอร์โทร",
@ -187,6 +180,17 @@ export class Profile extends EntityBase {
@ManyToOne(() => Relationship, (v) => v.profile) @ManyToOne(() => Relationship, (v) => v.profile)
relationship: Relationship; relationship: Relationship;
@Column({
nullable: true,
comment: "ศาสนา",
length: 255,
default: null,
})
religionId: string;
@ManyToOne(() => Religion, (v) => v.profile)
religion: Religion;
@Column({ @Column({
nullable: true, nullable: true,
comment: "กรุ๊ปเลือด", comment: "กรุ๊ปเลือด",
@ -286,9 +290,9 @@ export class CreateProfile {
dateRetire: Date | null; dateRetire: Date | null;
birthDate: Date | null; birthDate: Date | null;
ethnicity: string | null; ethnicity: string | null;
religion: string | null;
telephoneNumber: string | null; telephoneNumber: string | null;
citizenId: string; citizenId: string;
religionId: string | null;
posLevelId: string | null; posLevelId: string | null;
posTypeId: string | null; posTypeId: string | null;
genderId: string | null; genderId: string | null;
@ -308,9 +312,9 @@ export type UpdateProfile = {
dateRetire?: Date | null; dateRetire?: Date | null;
birthDate?: Date | null; birthDate?: Date | null;
ethnicity?: string | null; ethnicity?: string | null;
religion?: string | null;
telephoneNumber?: string | null; telephoneNumber?: string | null;
citizenId?: string | null; citizenId?: string | null;
religionId: string | null;
posLevelId?: string | null; posLevelId?: string | null;
posTypeId?: string | null; posTypeId?: string | null;
genderId?: string | null; genderId?: string | null;

View file

@ -8,6 +8,7 @@ import { ProfileDisciplineEmployee } from "./ProfileDisciplineEmployee";
import { BloodGroup } from "./BloodGroup"; import { BloodGroup } from "./BloodGroup";
import { Relationship } from "./Relationship"; import { Relationship } from "./Relationship";
import { Gender } from "./Gender"; import { Gender } from "./Gender";
import { Religion } from "./Religion";
@Entity("profileEmployee") @Entity("profileEmployee")
export class ProfileEmployee extends EntityBase { export class ProfileEmployee extends EntityBase {
@ -125,14 +126,6 @@ export class ProfileEmployee extends EntityBase {
}) })
ethnicity: string; ethnicity: string;
@Column({
nullable: true,
comment: "ศาสนา",
length: 255,
default: null,
})
religion: string;
@Column({ @Column({
nullable: true, nullable: true,
comment: "เบอร์โทร", comment: "เบอร์โทร",
@ -163,6 +156,17 @@ export class ProfileEmployee extends EntityBase {
@ManyToOne(() => Relationship, (v) => v.profileEmployee) @ManyToOne(() => Relationship, (v) => v.profileEmployee)
relationship: Relationship; relationship: Relationship;
@Column({
nullable: true,
comment: "ศาสนา",
length: 255,
default: null,
})
religionId: string;
@ManyToOne(() => Religion, (v) => v.profile)
religion: Religion;
@Column({ @Column({
nullable: true, nullable: true,
comment: "กรุ๊ปเลือด", comment: "กรุ๊ปเลือด",
@ -220,9 +224,9 @@ export class CreateProfileEmployee {
birthDate: Date | null; birthDate: Date | null;
salaryLevel: number | null; salaryLevel: number | null;
ethnicity: string | null; ethnicity: string | null;
religion: string | null;
telephoneNumber: string | null; telephoneNumber: string | null;
citizenId: string; citizenId: string;
religionId: string | null;
posLevelId: string | null; posLevelId: string | null;
posTypeId: string | null; posTypeId: string | null;
genderId: string | null; genderId: string | null;
@ -240,9 +244,9 @@ export type UpdateProfileEmployee = {
birthDate?: Date | null; birthDate?: Date | null;
salaryLevel?: number | null; salaryLevel?: number | null;
ethnicity?: string | null; ethnicity?: string | null;
religion?: string | null;
telephoneNumber?: string | null; telephoneNumber?: string | null;
citizenId?: string; citizenId?: string;
religionId: string | null;
posLevelId?: string | null; posLevelId?: string | null;
posTypeId?: string | null; posTypeId?: string | null;
genderId?: string | null; genderId?: string | null;

View file

@ -1,5 +1,7 @@
import { Entity, Column} from "typeorm"; import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base"; import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("religion") @Entity("religion")
export class Religion extends EntityBase { export class Religion extends EntityBase {
@ -10,6 +12,12 @@ export class Religion extends EntityBase {
default: null, default: null,
}) })
name: string; name: string;
@OneToMany(() => Profile, (v) => v.religion)
profile: Profile[];
@OneToMany(() => ProfileEmployee, (v) => v.religion)
profileEmployee: ProfileEmployee[];
} }
export class CreateReligion { export class CreateReligion {