refactor!: merge information into profile
This commit is contained in:
parent
fc712baa8f
commit
122e00d065
5 changed files with 119 additions and 200 deletions
|
|
@ -1,7 +1,6 @@
|
||||||
import { Entity, Column, OneToMany } from "typeorm";
|
import { Entity, Column, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { Profile } from "./Profile";
|
||||||
import { ProfileInformation } from "./ProfileInformation";
|
|
||||||
|
|
||||||
@Entity("bloodGroup")
|
@Entity("bloodGroup")
|
||||||
export class BloodGroup extends EntityBase {
|
export class BloodGroup extends EntityBase {
|
||||||
|
|
@ -13,8 +12,8 @@ export class BloodGroup extends EntityBase {
|
||||||
})
|
})
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.bloodGroupId)
|
@OneToMany(() => Profile, (v) => v.bloodGroup)
|
||||||
profileInformations: ProfileInformation[];
|
profile: Profile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateBloodGroup {
|
export class CreateBloodGroup {
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
import { Entity, Column, OneToMany } from "typeorm";
|
import { Entity, Column, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { Profile } from "./Profile";
|
||||||
import { ProfileInformation } from "./ProfileInformation";
|
|
||||||
|
|
||||||
@Entity("gender")
|
@Entity("gender")
|
||||||
export class Gender extends EntityBase {
|
export class Gender extends EntityBase {
|
||||||
|
|
@ -13,8 +12,8 @@ export class Gender extends EntityBase {
|
||||||
})
|
})
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.genderId)
|
@OneToMany(() => Profile, (v) => v.gender)
|
||||||
profileInformations: ProfileInformation[];
|
profile: Profile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateGender {
|
export class CreateGender {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Entity, Column, OneToMany, OneToOne, JoinColumn, ManyToMany, ManyToOne } from "typeorm";
|
import { Entity, Column, OneToMany, JoinColumn, ManyToOne } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { PosMaster } from "./PosMaster";
|
import { PosMaster } from "./PosMaster";
|
||||||
import { PosLevel } from "./PosLevel";
|
import { PosLevel } from "./PosLevel";
|
||||||
|
|
@ -16,9 +16,11 @@ import { ProfileAbility } from "./ProfileAbility";
|
||||||
import { ProfileDuty } from "./ProfileDuty";
|
import { ProfileDuty } from "./ProfileDuty";
|
||||||
import { ProfileNopaid } from "./ProfileNopaid";
|
import { ProfileNopaid } from "./ProfileNopaid";
|
||||||
import { ProfileOther } from "./ProfileOther";
|
import { ProfileOther } from "./ProfileOther";
|
||||||
import { ProfileInformation } from "./ProfileInformation";
|
|
||||||
import { ProfileFamilyHistory } from "./ProfileFamily";
|
import { ProfileFamilyHistory } from "./ProfileFamily";
|
||||||
import { ProfileGovernment } from "./ProfileGovernment";
|
import { ProfileGovernment } from "./ProfileGovernment";
|
||||||
|
import { Gender } from "./Gender";
|
||||||
|
import { Relationship } from "./Relationship";
|
||||||
|
import { BloodGroup } from "./BloodGroup";
|
||||||
|
|
||||||
@Entity("profile")
|
@Entity("profile")
|
||||||
export class Profile extends EntityBase {
|
export class Profile extends EntityBase {
|
||||||
|
|
@ -139,6 +141,63 @@ export class Profile extends EntityBase {
|
||||||
})
|
})
|
||||||
birthDate: Date;
|
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;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "เพศ",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
genderId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Gender, (v) => v.profile)
|
||||||
|
gender: Gender;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "ความสัมพันธ์",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
relationshipId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Relationship, (v) => v.profile)
|
||||||
|
relationship: Relationship;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
comment: "กรุ๊ปเลือด",
|
||||||
|
length: 40,
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
bloodGroupId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => BloodGroup, (v) => v.profile)
|
||||||
|
bloodGroup: BloodGroup;
|
||||||
|
|
||||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
|
@OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder)
|
||||||
current_holders: PosMaster[];
|
current_holders: PosMaster[];
|
||||||
|
|
||||||
|
|
@ -190,6 +249,9 @@ export class Profile extends EntityBase {
|
||||||
@OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile)
|
@OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile)
|
||||||
profileGovernment: ProfileGovernment[];
|
profileGovernment: ProfileGovernment[];
|
||||||
|
|
||||||
|
@OneToMany(() => ProfileHistory, (v) => v.profile)
|
||||||
|
histories: ProfileHistory[];
|
||||||
|
|
||||||
@ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles)
|
@ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles)
|
||||||
@JoinColumn({ name: "posLevelId" })
|
@JoinColumn({ name: "posLevelId" })
|
||||||
posLevel: PosLevel;
|
posLevel: PosLevel;
|
||||||
|
|
@ -197,32 +259,61 @@ export class Profile extends EntityBase {
|
||||||
@ManyToOne(() => PosType, (posType) => posType.profiles)
|
@ManyToOne(() => PosType, (posType) => posType.profiles)
|
||||||
@JoinColumn({ name: "posTypeId" })
|
@JoinColumn({ name: "posTypeId" })
|
||||||
posType: PosType;
|
posType: PosType;
|
||||||
|
}
|
||||||
|
|
||||||
@OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.profile)
|
@Entity("profileHistory")
|
||||||
profileInformation: ProfileInformation[];
|
export class ProfileHistory extends Profile {
|
||||||
|
@Column({
|
||||||
|
nullable: true,
|
||||||
|
length: 40,
|
||||||
|
comment: "คีย์นอก(FK)ของตาราง ProfileInformation",
|
||||||
|
default: null,
|
||||||
|
})
|
||||||
|
profileId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => Profile, (v) => v.histories, { onDelete: "CASCADE" })
|
||||||
|
profile: Profile;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProfile {
|
export class CreateProfile {
|
||||||
@Column()
|
|
||||||
prefix: string;
|
prefix: string;
|
||||||
|
|
||||||
@Column()
|
|
||||||
firstName: string;
|
firstName: string;
|
||||||
|
|
||||||
@Column()
|
|
||||||
lastName: string;
|
lastName: string;
|
||||||
|
|
||||||
@Column()
|
|
||||||
citizenId: string;
|
|
||||||
|
|
||||||
@Column()
|
|
||||||
position: string;
|
position: string;
|
||||||
|
email: string | null;
|
||||||
@Column("uuid")
|
phone: string | null;
|
||||||
|
isProbation: boolean | null;
|
||||||
|
dateRetire: Date | null;
|
||||||
|
birthDate: Date | null;
|
||||||
|
ethnicity: string | null;
|
||||||
|
religion: string | null;
|
||||||
|
telephoneNumber: string | null;
|
||||||
|
citizenId: string;
|
||||||
posLevelId: string | null;
|
posLevelId: string | null;
|
||||||
|
|
||||||
@Column("uuid")
|
|
||||||
posTypeId: string | null;
|
posTypeId: string | null;
|
||||||
|
genderId: string | null;
|
||||||
|
relationshipId: string | null;
|
||||||
|
bloodGroupId: string | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdateProfile = Partial<CreateProfile>;
|
export type UpdateProfile = {
|
||||||
|
prefix?: string | null;
|
||||||
|
firstName?: string | null;
|
||||||
|
lastName?: string | null;
|
||||||
|
position?: string | null;
|
||||||
|
email?: string | null;
|
||||||
|
phone?: string | null;
|
||||||
|
keycloak?: string | null;
|
||||||
|
isProbation?: boolean | null;
|
||||||
|
dateRetire?: Date | null;
|
||||||
|
birthDate?: Date | null;
|
||||||
|
ethnicity?: string | null;
|
||||||
|
religion?: string | null;
|
||||||
|
telephoneNumber?: string | null;
|
||||||
|
citizenId?: string | null;
|
||||||
|
posLevelId?: string | null;
|
||||||
|
posTypeId?: string | null;
|
||||||
|
genderId?: string | null;
|
||||||
|
relationshipId?: string | null;
|
||||||
|
bloodGroupId?: string | null;
|
||||||
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,169 +0,0 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
|
||||||
import { EntityBase } from "./base/Base";
|
|
||||||
|
|
||||||
import { Profile } from "./Profile";
|
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
@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;
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
import { Entity, Column, OneToMany } from "typeorm";
|
import { Entity, Column, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
|
||||||
import { ProfileInformation } from "./ProfileInformation";
|
import { Profile } from "./Profile";
|
||||||
|
|
||||||
@Entity("relationship")
|
@Entity("relationship")
|
||||||
export class Relationship extends EntityBase {
|
export class Relationship extends EntityBase {
|
||||||
|
|
@ -13,12 +13,11 @@ export class Relationship extends EntityBase {
|
||||||
})
|
})
|
||||||
name: string;
|
name: string;
|
||||||
|
|
||||||
@OneToMany(() => ProfileInformation, (profileInformation) => profileInformation.relationshipId)
|
@OneToMany(() => Profile, (v) => v.relationship)
|
||||||
profileInformations: ProfileInformation[];
|
profile: Profile[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateRelationship {
|
export class CreateRelationship {
|
||||||
@Column()
|
|
||||||
name: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue