family entity (father, mother, couple)

This commit is contained in:
Bright 2024-05-14 17:39:32 +07:00
parent 291d3199d2
commit 968842557a
8 changed files with 575 additions and 0 deletions

View file

@ -0,0 +1,112 @@
import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
import { ProfileFamilyMotherHistory } from "./ProfileFamilyMotherHistory";
@Entity("profileFamilyMother")
export class ProfileFamilyMother extends EntityBase {
@Column({
nullable: true,
default: null,
comment: "คำนำหน้ามารดา",
})
motherPrefix: string;
@Column({
nullable: true,
default: null,
comment: "ชื่อมารดา",
})
motherFirstName: string;
@Column({
nullable: true,
default: null,
comment: "นามสกุลมารดา",
})
motherLastName: string;
@Column({
nullable: true,
default: null,
comment: "อาชีพบิดา",
})
motherCareer: string;
@Column({
nullable: true,
default: null,
comment: "เลขที่บัตรประชาชนมารดา",
})
motherCitizenId: string;
@Column({
nullable: true,
default: null,
comment: "มีชีวิตมารดา",
})
motherLive: boolean;
@Column({
nullable: true,
length: 40,
type: "uuid",
comment: "คีย์นอก(FK) ของตาราง Profile",
default: null,
})
profileId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileEmployee",
default: null,
})
profileEmployeeId: string;
@OneToMany(
() => ProfileFamilyMotherHistory,
(v) => v.histories,
)
profileFamilyMother: ProfileFamilyMotherHistory[];
@ManyToOne(() => Profile, (v) => v.profileFamilyMother)
@JoinColumn({ name: "profileId" })
profile: Profile;
@ManyToOne(() => ProfileEmployee, (v) => v.profileFamilyMother)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
export type CreateProfileFamilyMother = {
profileId: string;
motherPrefix: string | null;
motherFirstName: string | null;
motherLastName: string | null;
motherCareer: string | null;
motherCitizenId: string | null;
motherLive: boolean | null;
}
export type CreateProfileEmployeeFamilyMother= {
profileEmployeeId: string;
motherPrefix: string | null;
motherFirstName: string | null;
motherLastName: string | null;
motherCareer: string | null;
motherCitizenId: string | null;
motherLive: boolean | null;
}
export type UpdateProfileFamilyMother= {
motherPrefix: string | null;
motherFirstName: string | null;
motherLastName: string | null;
motherCareer: string | null;
motherCitizenId: string | null;
motherLive: boolean | null;
};