From 049b591c77f94107b4e116fdb3e38621d7ef1d13 Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Wed, 20 Mar 2024 09:08:42 +0700 Subject: [PATCH] =?UTF-8?q?refactor:=20=E0=B9=80=E0=B8=9E=E0=B8=B4?= =?UTF-8?q?=E0=B9=88=E0=B8=A1=20table=20profileinformation=20=20=E0=B9=81?= =?UTF-8?q?=E0=B8=A5=E0=B8=B0=20profileinformationhistory?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/entities/ProfileInformation.ts | 154 ++++++++++++++++++++++ src/entities/ProfileInformationHistory.ts | 18 +++ 2 files changed, 172 insertions(+) create mode 100644 src/entities/ProfileInformation.ts create mode 100644 src/entities/ProfileInformationHistory.ts diff --git a/src/entities/ProfileInformation.ts b/src/entities/ProfileInformation.ts new file mode 100644 index 00000000..6ee1490a --- /dev/null +++ b/src/entities/ProfileInformation.ts @@ -0,0 +1,154 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; +import { EntityBase } from "./base/Base"; + +import { Profile } from "./Profile"; +import { ProfileInformationHistory } from "./ProfileInformationHistory"; +import { BloodGroup } from "./BloodGroup"; +import { Relationship } from "./Relationship"; +import { Gender } from "./Gender"; +@Entity("profileinformation") +export class ProfileInformation extends EntityBase { + @Column({ + nullable: true, + comment: "เลขประจำตัวประชาชน", + default: null, + length: 13, + }) + citizenId: string; + + @Column({ + nullable: true, + comment: "คำนำหน้าชื่อ", + length: 40, + default: null, + }) + prefix: string; + + @Column({ + nullable: true, + comment: "ชื่อ", + length: 255, + default: null, + }) + firstName: string; + + @Column({ + nullable: true, + comment: "นามสกุล", + length: 255, + default: null, + }) + lastName: string; + + @Column({ + nullable: true, + type: "datetime", + comment: "วันเกิด", + default: null, + }) + birthDate: Date; + + @Column({ + nullable: true, + comment: "เชื้อชาติ", + length: 255, + default: null, + }) + ethnicity: string; + + @Column({ + nullable: true, + comment: "ศาสนา", + length: 255, + default: null, + }) + religion: string; + + @Column({ + nullable: true, + comment: "เบอร์โทร", + length: 255, + default: null, + }) + telephoneNumber: string; + + @OneToMany(() => ProfileInformationHistory, (v) => v.profileInformation) + profileInformationHistory: ProfileInformationHistory[]; + + @Column({ + nullable: true, + comment: "เพศ", + length: 40, + default: null, + }) + genderId: string; + + @ManyToOne(() => Gender, (v) => v.profileInformations) + @JoinColumn({ name: "genderId" }) + gender: Gender; + + @Column({ + nullable: true, + comment: "ความสัมพันธ์", + length: 40, + default: null, + }) + relationshipId: string; + + @ManyToOne(() => Relationship, (v) => v.profileInformations) + @JoinColumn({ name: "relationshipId" }) + relationship: Relationship; + + @Column({ + nullable: true, + comment: "กรุ๊ปเลือด", + length: 40, + default: null, + }) + bloodGroupId: string; + + @ManyToOne(() => BloodGroup, (v) => v.profileInformations) + @JoinColumn({ name: "bloodGroupId" }) + bloodGroup: BloodGroup; + + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง Profile", + default: null, + }) + profileId: string; + + @ManyToOne(() => Profile, (v) => v.profileInformation) + @JoinColumn({ name: "profileId" }) + profile: Profile; +} + +export class CreateProfileInformation { + profileId: string | null; + citizenId: string | null; + prefix: string | null; + firstName: string | null; + lastName: string | null; + birthDate: Date | null; + ethnicity: string | null; + religion: string | null; + telephoneNumber: string | null; + genderId: string | null; + relationshipId: string | null; + bloodGroupId: string | null; +} + +export type UpdateProfileInformation = { + citizenId?: string | null; + prefix?: string | null; + firstName?: string | null; + lastName?: string | null; + birthDate?: Date | null; + ethnicity?: string | null; + religion?: string | null; + telephoneNumber?: string | null; + genderId?: string | null; + relationshipId?: string | null; + bloodGroupId?: string | null; +}; diff --git a/src/entities/ProfileInformationHistory.ts b/src/entities/ProfileInformationHistory.ts new file mode 100644 index 00000000..c7c04b27 --- /dev/null +++ b/src/entities/ProfileInformationHistory.ts @@ -0,0 +1,18 @@ +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; + +import { ProfileInformation } from "./ProfileInformation"; + +@Entity("profileinformationHistory") +export class ProfileInformationHistory extends ProfileInformation { + @Column({ + nullable: true, + length: 40, + comment: "คีย์นอก(FK)ของตาราง ProfileInformation", + default: null, + }) + profileInformationId: string; + + @ManyToOne(() => ProfileInformation, (v) => v.profileInformationHistory, { onDelete: "CASCADE" }) + @JoinColumn({ name: "profileInformationId" }) + profileInformation: ProfileInformation; +}