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 { 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;

View file

@ -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;

View file

@ -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 {