diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index 6fbfd362..3b01f4b3 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -16,6 +16,7 @@ import { ProfileAbility } from "./ProfileAbility"; import { ProfileDuty } from "./ProfileDuty"; import { ProfileNopaid } from "./ProfileNopaid"; import { ProfileOther } from "./ProfileOther"; +import { ProfileFamilyHistory } from "./ProfileFamily"; @Entity("profile") export class Profile extends EntityBase { @@ -181,6 +182,9 @@ export class Profile extends EntityBase { @OneToMany(() => ProfileOther, (profileOther) => profileOther.profile) profileOthers: ProfileOther[]; + @OneToMany(() => ProfileFamilyHistory, (profileFamily) => profileFamily.profile) + profileFamily: ProfileFamilyHistory[]; + @ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles) @JoinColumn({ name: "posLevelId" }) posLevel: PosLevel; diff --git a/src/entities/ProfileFamily.ts b/src/entities/ProfileFamily.ts new file mode 100644 index 00000000..f7377b70 --- /dev/null +++ b/src/entities/ProfileFamily.ts @@ -0,0 +1,335 @@ +import { Column, Entity, ManyToOne, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; + +@Entity("profileFamilyHistory") +export class ProfileFamilyHistory extends EntityBase { + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isActive: boolean; + + @Column({ + nullable: true, + default: null, + type: "boolean", + }) + couple: boolean; + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าคู่สมรส", + }) + couplePrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อคู่สมรส", + }) + coupleFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลคู่สมรส", + }) + coupleLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลคู่สมรส(เดิม)", + }) + coupleLastNameOld: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพคู่สมรส", + }) + coupleCareer: string; + + @Column({ + nullable: true, + default: null, + length: 13, + comment: "เลขที่บัตรประชาชนคู่สมรส", + }) + coupleCitizenId: string; + + @Column({ + nullable: true, + default: null, + type: "boolean", + comment: "มีชีวิตคู่สมรส", + }) + coupleLive: boolean; + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบิดา", + }) + fatherPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบิดา", + }) + fatherFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบิดา", + }) + fatherLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบิดา", + }) + fatherCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบิดา", + }) + fatherCitizenId: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตบิดา", + }) + fatherLive: boolean; + + @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; + + @ManyToOne(() => Profile, (v) => v.profileFamily) + profile: Profile; + + @OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory) + profileChildrenHistories: ProfileChildrenHistory[]; +} + +@Entity("profileChildren") +export class ProfileChildren extends EntityBase { + @Column({ + comment: "สถานะการใช้งาน", + default: false, + }) + isActive: boolean; + + @Column({ + nullable: true, + default: null, + comment: "อาชีพบุตร", + }) + childrenCareer: string; + + @Column({ + nullable: true, + default: null, + comment: "ชื่อบุตร", + }) + childrenFirstName: string; + + @Column({ + nullable: true, + default: null, + comment: "นามสกุลบุตร", + }) + childrenLastName: string; + + @Column({ + nullable: true, + default: null, + comment: "คำนำหน้าบุตร", + }) + childrenPrefix: string; + + @Column({ + nullable: true, + default: null, + comment: "มีชีวิตบุตร", + }) + childrenLive: string; + + @Column({ + nullable: true, + default: null, + comment: "เลขที่บัตรประชาชนบุตร", + }) + childrenCitizenId: string; + + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileId: string; + + @ManyToOne(() => Profile, (v) => v.profileFamily, { onDelete: "CASCADE" }) + profile: Profile; + + @OneToMany(() => ProfileChildrenHistory, (v) => v.profileChildren) + histories: Profile; +} + +@Entity("profileChildrenHistory") +export class ProfileChildrenHistory extends ProfileChildren { + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileFamilyHistoryId: string; + + @ManyToOne(() => ProfileFamilyHistory, (v) => v.profileChildrenHistories, { onDelete: "CASCADE" }) + profileFamilyHistory: ProfileFamilyHistory; + + @Column({ + nullable: true, + length: 40, + type: "uuid", + comment: "คีย์นอก(FK) ของตาราง Profile", + default: null, + }) + profileChildrenId: string; + + @ManyToOne(() => ProfileChildren, (v) => v.histories, { onDelete: "CASCADE" }) + profileChildren: ProfileChildren; +} + +type CreateChildren = { + isActive: boolean; + childrenCareer: string; + childrenFirstName: string; + childrenLastName: string; + childrenPrefix: string; + childrenLive: string; + childrenCitizenId: string; +}; + +type UpdateChildren = { + id: string; + isActive?: boolean | null; + childrenCareer?: string | null; + childrenFirstName?: string | null; + childrenLastName?: string | null; + childrenPrefix?: string | null; + childrenLive?: string | null; + childrenCitizenId?: string | null; +}; + +export type CreateProfileFamily = { + isActive: boolean | null; + couple: boolean | null; + couplePrefix: string | null; + coupleFirstName: string | null; + coupleLastName: string | null; + coupleLastNameOld: string | null; + coupleCareer: string | null; + coupleCitizenId: string | null; + coupleLive: boolean | null; + fatherPrefix: string | null; + fatherFirstName: string | null; + fatherLastName: string | null; + fatherCareer: string | null; + fatherCitizenId: string | null; + fatherLive: boolean | null; + motherPrefix: string | null; + motherFirstName: string | null; + motherLastName: string | null; + motherCareer: string | null; + motherCitizenId: string | null; + motherLive: boolean | null; + profileId: string; + children: CreateChildren[]; +}; + +export type UpdateProfileFamily = { + id: string; + isActive?: boolean | null; + couple?: boolean | null; + couplePrefix?: string | null; + coupleFirstName?: string | null; + coupleLastName?: string | null; + coupleLastNameOld?: string | null; + coupleCareer?: string | null; + coupleCitizenId?: string | null; + coupleLive?: boolean | null; + fatherPrefix?: string | null; + fatherFirstName?: string | null; + fatherLastName?: string | null; + fatherCareer?: string | null; + fatherCitizenId?: string | null; + fatherLive?: boolean | null; + motherPrefix?: string | null; + motherFirstName?: string | null; + motherLastName?: string | null; + motherCareer?: string | null; + motherCitizenId?: string | null; + motherLive?: boolean | null; + children: UpdateChildren[]; +};