แก้ไขบุตร

This commit is contained in:
Kittapath 2024-05-14 17:26:06 +07:00
parent 291d3199d2
commit 0114e41c3a
7 changed files with 511 additions and 106 deletions

View file

@ -16,12 +16,13 @@ import { ProfileAbility } from "./ProfileAbility";
import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileOther } from "./ProfileOther";
import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileGovernment } from "./ProfileGovernment";
import { Province } from "./Province";
import { SubDistrict } from "./SubDistrict";
import { District } from "./District";
import { ProfileAvatar } from "./ProfileAvatar";
import { ProfileChildren } from "./ProfileChildren";
@Entity("profile")
export class Profile extends EntityBase {
@ -309,7 +310,7 @@ export class Profile extends EntityBase {
profileFamily: ProfileFamilyHistory[];
@OneToMany(() => ProfileChildren, (profileChildren) => profileChildren.profile)
profileChildren: ProfileChildren[];
profileChildrens: ProfileChildren[];
@OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile)
profileGovernment: ProfileGovernment[];

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 { ProfileChildrenHistory } from "./ProfileChildrenHistory";
@Entity("profileChildren")
export class ProfileChildren extends EntityBase {
@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,
type: "boolean",
comment: "มีชีวิตบุตร",
})
childrenLive: boolean;
@Column({
nullable: true,
default: null,
comment: "เลขที่บัตรประชาชนบุตร",
})
childrenCitizenId: string;
@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;
@ManyToOne(() => Profile, (Profile) => Profile.profileChildrens)
@JoinColumn({ name: "profileId" })
profile: Profile;
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileChildrens)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
@OneToMany(
() => ProfileChildrenHistory,
(profileChildrenHistory) => profileChildrenHistory.histories,
)
profileChildrenHistories: ProfileChildrenHistory[];
}
export type CreateProfileChildren = {
profileId: string;
childrenCareer: string;
childrenFirstName: string;
childrenLastName: string;
childrenPrefix: string;
childrenLive: boolean;
childrenCitizenId: string;
};
export type CreateProfileChildrenEmployee = {
profileEmployeeId: string;
childrenCareer: string;
childrenFirstName: string;
childrenLastName: string;
childrenPrefix: string;
childrenLive: boolean;
childrenCitizenId: string;
};
export type UpdateProfileChildren = {
id: string;
childrenCareer?: string | null;
childrenFirstName?: string | null;
childrenLastName?: string | null;
childrenPrefix?: string | null;
childrenLive?: boolean | null;
childrenCitizenId?: string | null;
};

View file

@ -0,0 +1,155 @@
import { Column, Entity, ManyToOne, OneToMany, JoinColumn } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
import { ProfileChildren } from "./ProfileChildren";
@Entity("profileChildrenHistory")
export class ProfileChildrenHistory extends EntityBase {
@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,
type: "boolean",
comment: "มีชีวิตบุตร",
})
childrenLive: boolean;
@Column({
nullable: true,
default: null,
comment: "เลขที่บัตรประชาชนบุตร",
})
childrenCitizenId: string;
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileChildren",
default: null,
})
profileChildrenId: string;
@ManyToOne(() => ProfileChildren, (profileChildren) => profileChildren.profileChildrenHistories)
@JoinColumn({ name: "profileChildrenId" })
histories: ProfileChildren;
}
export type CreateChildren = {
childrenCareer: string;
childrenFirstName: string;
childrenLastName: string;
childrenPrefix: string;
childrenLive: boolean;
childrenCitizenId: string;
};
export type UpdateChildren = {
id: string;
childrenCareer?: string | null;
childrenFirstName?: string | null;
childrenLastName?: string | null;
childrenPrefix?: string | null;
childrenLive?: boolean | null;
childrenCitizenId?: string | null;
};
export type CreateProfileFamily = {
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 CreateProfileFamilyEmployee = {
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;
profileEmployeeId: string | null;
children: CreateChildren[];
};
export type UpdateProfileFamily = {
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[];
};

View file

@ -15,12 +15,13 @@ import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileDiscipline } from "./ProfileDiscipline";
import { ProfileChangeName } from "./ProfileChangeName";
import { ProfileChildren, ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileFamilyHistory } from "./ProfileFamily";
import { ProfileEducation } from "./ProfileEducation";
import { ProfileAbility } from "./ProfileAbility";
import { ProfileOther } from "./ProfileOther";
import { ProfileAvatar } from "./ProfileAvatar";
import { ProfileGovernment } from "./ProfileGovernment";
import { ProfileChildren } from "./ProfileChildren";
@Entity("profileEmployee")
export class ProfileEmployee extends EntityBase {
@Column({

View file

@ -167,114 +167,11 @@ export class ProfileFamilyHistory extends EntityBase {
@ManyToOne(() => Profile, (v) => v.profileFamily)
profile: Profile;
@OneToMany(() => ProfileChildrenHistory, (v) => v.profileFamilyHistory)
profileChildrenHistories: ProfileChildrenHistory[];
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileFamilys)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
@Entity("profileChildren")
export class ProfileChildren extends EntityBase {
@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,
type: "boolean",
comment: "มีชีวิตบุตร",
})
childrenLive: boolean;
@Column({
nullable: true,
default: null,
comment: "เลขที่บัตรประชาชนบุตร",
})
childrenCitizenId: string;
@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;
@ManyToOne(() => Profile, (v) => v.profileFamily, { onDelete: "CASCADE" })
profile: Profile;
@OneToMany(() => ProfileChildrenHistory, (v) => v.profileChildren)
histories: Profile;
@ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileChildrens)
@JoinColumn({ name: "profileEmployeeId" })
profileEmployee: ProfileEmployee;
}
@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;
}
export type CreateChildren = {
childrenCareer: string;
childrenFirstName: string;