hrms-api-org/src/entities/ProfileChildren.ts

116 lines
2.8 KiB
TypeScript
Raw Normal View History

2024-05-14 17:26:06 +07:00
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;
2024-05-15 18:02:16 +07:00
// @OneToMany(
// () => ProfileChildrenHistory,
// (profileChildrenHistory) => profileChildrenHistory.histories,
// )
// profileChildrenHistories: ProfileChildrenHistory[];
@OneToMany(() => ProfileChildrenHistory, (v) => v.profileChildrenHistories)
histories: ProfileChildrenHistory[];
2024-05-14 17:26:06 +07:00
}
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 = {
2024-05-15 18:02:16 +07:00
// id: string;
2024-05-14 17:26:06 +07:00
childrenCareer?: string | null;
childrenFirstName?: string | null;
childrenLastName?: string | null;
childrenPrefix?: string | null;
childrenLive?: boolean | null;
childrenCitizenId?: string | null;
};