feat: profile employee with more info

This commit is contained in:
Methapon2001 2024-03-21 11:28:02 +07:00
parent 4b61617123
commit 3c21e5351a
4 changed files with 126 additions and 92 deletions

View file

@ -1,6 +1,7 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("bloodGroup")
export class BloodGroup extends EntityBase {
@ -14,6 +15,9 @@ export class BloodGroup extends EntityBase {
@OneToMany(() => Profile, (v) => v.bloodGroup)
profile: Profile[];
@OneToMany(() => Profile, (v) => v.bloodGroup)
profileEmployee: ProfileEmployee[];
}
export class CreateBloodGroup {

View file

@ -1,6 +1,7 @@
import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("gender")
export class Gender extends EntityBase {
@ -14,6 +15,9 @@ export class Gender extends EntityBase {
@OneToMany(() => Profile, (v) => v.gender)
profile: Profile[];
@OneToMany(() => ProfileEmployee, (v) => v.gender)
profileEmployee: ProfileEmployee[];
}
export class CreateGender {

View file

@ -1,26 +1,13 @@
import { Entity, Column, OneToMany, OneToOne, JoinColumn, ManyToMany, ManyToOne } from "typeorm";
import { Entity, Column, OneToMany, ManyToOne } from "typeorm";
import { EntityBase } from "./base/Base";
import { PosMaster } from "./PosMaster";
import { PosLevel } from "./PosLevel";
import { PosType } from "./PosType";
import { ProfileSalary } from "./ProfileSalary";
import { ProfileDiscipline } from "./ProfileDiscipline";
import { ProfileCertificate } from "./ProfileCertificate";
import { ProfileEducation } from "./ProfileEducation";
import { ProfileTraining } from "./ProfileTraining";
import { ProfileInsignia } from "./ProfileInsignia";
import { ProfileHonor } from "./ProfileHonor";
import { ProfileAssessment } from "./ProfileAssessment";
import { ProfileLeave } from "./ProfileLeave";
import { ProfileAbility } from "./ProfileAbility";
import { ProfileDuty } from "./ProfileDuty";
import { ProfileNopaid } from "./ProfileNopaid";
import { ProfileOther } from "./ProfileOther";
import { EmployeePosLevel } from "./EmployeePosLevel";
import { EmployeePosType } from "./EmployeePosType";
import { EmployeePosMaster } from "./EmployeePosMaster";
import { ProfileSalaryEmployee } from "./ProfileSalaryEmployee";
import { ProfileDisciplineEmployee } from "./ProfileDisciplineEmployee";
import { BloodGroup } from "./BloodGroup";
import { Relationship } from "./Relationship";
import { Gender } from "./Gender";
@Entity("profileEmployee")
export class ProfileEmployee extends EntityBase {
@ -92,25 +79,6 @@ export class ProfileEmployee extends EntityBase {
})
phone: string;
// @Column({
// nullable: true,
// length: 40,
// comment:
// "คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้",
// default: null,
// unique: false,
// })
// current_holderId: string;
// @Column({
// nullable: true,
// length: 40,
// comment:
// "คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย",
// default: null,
// unique: false,
// })
// next_holderId: string;
@Column({
nullable: true,
comment: "id keycloak",
@ -149,81 +117,135 @@ export class ProfileEmployee extends EntityBase {
})
salaryLevel: number | null;
@OneToMany(() => EmployeePosMaster, (posMaster) => posMaster.current_holder)
@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.profileEmployee)
gender: Gender;
@Column({
nullable: true,
comment: "ความสัมพันธ์",
length: 40,
default: null,
})
relationshipId: string;
@ManyToOne(() => Relationship, (v) => v.profileEmployee)
relationship: Relationship;
@Column({
nullable: true,
comment: "กรุ๊ปเลือด",
length: 40,
default: null,
})
bloodGroupId: string;
@ManyToOne(() => BloodGroup, (v) => v.profileEmployee)
bloodGroup: BloodGroup;
@OneToMany(() => EmployeePosMaster, (v) => v.current_holder)
current_holders: EmployeePosMaster[];
@OneToMany(() => EmployeePosMaster, (posMaster) => posMaster.next_holder)
@OneToMany(() => EmployeePosMaster, (v) => v.next_holder)
next_holders: EmployeePosMaster[];
@OneToMany(() => ProfileSalaryEmployee, (profileSalary) => profileSalary.profile)
@OneToMany(() => ProfileSalaryEmployee, (v) => v.profile)
profileSalary: ProfileSalaryEmployee[];
@OneToMany(() => ProfileDisciplineEmployee, (profileDiscipline) => profileDiscipline.profile)
@OneToMany(() => ProfileDisciplineEmployee, (v) => v.profile)
profileDiscipline: ProfileDisciplineEmployee[];
// @OneToMany(() => ProfileCertificate, (profileCertificate) => profileCertificate.profile)
// profileCertificates: ProfileCertificate[];
// @OneToMany(() => ProfileEducation, (profileEducation) => profileEducation.profile)
// profileEducations: ProfileEducation[];
// @OneToMany(() => ProfileTraining, (profileTraining) => profileTraining.profile)
// profileTrainings: ProfileTraining[];
// @OneToMany(() => ProfileInsignia, (profileInsignia) => profileInsignia.profile)
// profileInsignias: ProfileInsignia[];
// @OneToMany(() => ProfileHonor, (profileHonor) => profileHonor.profile)
// profileHonors: ProfileHonor[];
// @OneToMany(() => ProfileAssessment, (profileAssessment) => profileAssessment.profile)
// profileAssessments: ProfileAssessment[];
// @OneToMany(() => ProfileLeave, (profileLeave) => profileLeave.profile)
// profileLeaves: ProfileLeave[];
// @OneToMany(() => ProfileAbility, (profileAbility) => profileAbility.profile)
// profileAbilities: ProfileAbility[];
// @OneToMany(() => ProfileDuty, (profileDuty) => profileDuty.profile)
// profileDutys: ProfileDuty[];
// @OneToMany(() => ProfileNopaid, (profileNopaid) => profileNopaid.profile)
// profileNopaids: ProfileNopaid[];
// @OneToMany(() => ProfileOther, (profileOther) => profileOther.profile)
// profileOthers: ProfileOther[];
@ManyToOne(() => EmployeePosLevel, (posLevel) => posLevel.profiles)
@JoinColumn({ name: "posLevelId" })
@ManyToOne(() => EmployeePosLevel, (v) => v.profiles)
posLevel: EmployeePosLevel;
@ManyToOne(() => EmployeePosType, (posType) => posType.profiles)
@JoinColumn({ name: "posTypeId" })
@ManyToOne(() => EmployeePosType, (v) => v.profiles)
posType: EmployeePosType;
@OneToMany(() => ProfileEmployeeHistory, (v) => v.profileEmployee)
histories: ProfileEmployeeHistory[];
}
@Entity("profileEmployeeHistory")
export class ProfileEmployeeHistory extends ProfileEmployee {
@Column({
nullable: true,
length: 40,
comment: "คีย์นอก(FK)ของตาราง ProfileInformation",
default: null,
})
profileEmployeeId: string;
@ManyToOne(() => ProfileEmployee, (v) => v.histories, { onDelete: "CASCADE" })
profileEmployee: ProfileEmployee;
}
export class CreateProfileEmployee {
@Column()
prefix: string;
@Column()
firstName: string;
@Column()
lastName: string;
@Column()
citizenId: string;
@Column()
position: string;
@Column("uuid")
isProbation: boolean | null;
dateRetire: Date | null;
birthDate: Date | null;
salaryLevel: number | null;
ethnicity: string | null;
religion: string | null;
telephoneNumber: string | null;
citizenId: string;
posLevelId: string | null;
@Column("uuid")
posTypeId: string | null;
genderId: string | null;
relationshipId: string | null;
bloodGroupId: string | null;
}
export type UpdateProfileEmployee = Partial<CreateProfileEmployee>;
export type UpdateProfileEmployee = {
prefix?: string | null;
firstName?: string | null;
lastName?: string | null;
position?: string | null;
isProbation?: boolean | null;
dateRetire?: Date | null;
birthDate?: Date | null;
salaryLevel?: number | null;
ethnicity?: string | null;
religion?: string | null;
telephoneNumber?: string | null;
citizenId?: string;
posLevelId?: string | null;
posTypeId?: string | null;
genderId?: string | null;
relationshipId?: string | null;
bloodGroupId?: string | null;
};

View file

@ -2,6 +2,7 @@ import { Entity, Column, OneToMany } from "typeorm";
import { EntityBase } from "./base/Base";
import { Profile } from "./Profile";
import { ProfileEmployee } from "./ProfileEmployee";
@Entity("relationship")
export class Relationship extends EntityBase {
@ -15,6 +16,9 @@ export class Relationship extends EntityBase {
@OneToMany(() => Profile, (v) => v.relationship)
profile: Profile[];
@OneToMany(() => ProfileEmployee, (v) => v.relationship)
profileEmployee: ProfileEmployee[];
}
export class CreateRelationship {