import { Entity, Column, OneToMany, JoinColumn, ManyToOne, Double, ManyToMany, JoinTable, } from "typeorm"; import { EntityBase } from "./base/Base"; import { PosMaster } from "./PosMaster"; import { PosLevel } from "./PosLevel"; import { PosType } from "./PosType"; import { ProfileSalary } from "./ProfileSalary"; 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 { ProfileFamilyHistory } from "./ProfileFamily"; import { ProfileGovernment } from "./ProfileGovernment"; import { Province } from "./Province"; import { SubDistrict } from "./SubDistrict"; import { District } from "./District"; import { ProfileAvatar } from "./ProfileAvatar"; import { ProfileFamilyFather } from "./ProfileFamilyFather"; import { ProfileFamilyMother } from "./ProfileFamilyMother"; import { ProfileFamilyCouple } from "./ProfileFamilyCouple"; import { ProfileChildren } from "./ProfileChildren"; import { ProfileDiscipline } from "./ProfileDiscipline"; import { ProfileEmployee } from "./ProfileEmployee"; import { ProfileEdit } from "./ProfileEdit"; import { ProfileDevelopment } from "./ProfileDevelopment"; import { PermissionOrg } from "./PermissionOrg"; import { CommandSend } from "./CommandSend"; import { DevelopmentRequest } from "./DevelopmentRequest"; import { StateOperatorUser } from "./StateOperatorUser"; import { StateUserComment } from "./StateUserComment"; import { CommandSign } from "./CommandSign"; import { RoleKeycloak } from "./RoleKeycloak"; import { ProfileActposition } from "./ProfileActposition"; import { ProfileAssistance } from "./ProfileAssistance"; import { ProfileSalaryTemp } from "./ProfileSalaryTemp"; import { PositionSalaryEditHistory } from "./PositionSalaryEditHistory"; import { ProfileChangeName } from "./ProfileChangeName"; import { ProfileAbsentLate } from "./ProfileAbsentLate"; @Entity("profile") export class Profile extends EntityBase { @Column({ nullable: true, comment: "รูปถ่าย", default: null, type: "varchar", }) avatar: string | null; @Column({ nullable: true, comment: "รูปถ่าย", default: null, type: "varchar", }) avatarName: string | null; @Column({ nullable: true, comment: "ยศ", length: 40, default: null, }) rank: string; @Column({ nullable: true, comment: "คำนำหน้าชื่อ", length: 40, default: null, }) prefix: string; @Column({ nullable: true, comment: "คำนำหน้าชื่อตัวหลัก", length: 40, default: null, }) prefixMain: string; @Column({ nullable: true, comment: "ชื่อ", length: 255, default: null, }) firstName: string; @Column({ nullable: true, comment: "นามสกุล", length: 255, default: null, }) lastName: string; @Column({ nullable: true, comment: "เลขประจำตัวประชาชน", default: null, length: 13, }) citizenId: string; @Column({ nullable: true, comment: "ตำแหน่ง", default: null, length: 255, }) position: string; @Column({ nullable: true, length: 40, comment: "ไอดีระดับตำแหน่ง", }) posLevelId: string | null; @Column({ nullable: true, length: 40, comment: "ไอดีประเภทตำแหน่ง", }) posTypeId: string | null; @Column({ nullable: true, length: 255, comment: "อีเมล", }) email: string; @Column({ nullable: true, comment: "สถานะอีเมล", //VERIFIED = ยืนยัน, NOT_VERIFIED = ไม่ได้ยืนยัน default: null, }) statusEmail: string; @Column({ nullable: true, length: 20, comment: "เบอร์โทร", }) 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", length: 40, default: null, }) keycloak: string; @Column({ comment: "สถานะการถูกลบผู้ใช้งานใน keycloak", default: false, }) isDelete: boolean; @Column({ comment: "ทดลองปฏิบัติหน้าที่", default: false, }) isProbation: boolean; @Column({ comment: "พ้นราชการ", default: false, }) isLeave: boolean; @Column({ comment: "เกษียณ", default: false, }) isRetirement: boolean; @Column({ comment: "สถานะการใช้งาน", default: true, }) isActive: boolean; @Column({ nullable: true, comment: "เหตุผลเกษียณ", default: null, }) leaveReason: string; @Column({ nullable: true, type: "datetime", comment: "วันพ้นราชการ", default: null, }) dateLeave: Date; @Column({ nullable: true, type: "datetime", comment: "วันครบเกษียณอายุ", default: null, }) dateRetire: Date; @Column({ nullable: true, type: "datetime", comment: "วันที่บรรจุ", default: null, }) dateAppoint: Date; @Column({ nullable: true, type: "datetime", comment: "วันที่เกษียณอายุราชการตามกฏหมาย", default: null, }) dateRetireLaw: Date; @Column({ nullable: true, type: "datetime", comment: "วันที่เริ่มปฏิบัติราชการ", default: null, }) dateStart: Date; @Column({ nullable: true, comment: "ขาดราชการ", default: null, }) govAgeAbsent: number; @Column({ nullable: true, comment: "อายุราชการเกื้อกูล", default: null, }) govAgePlus: number; @Column({ nullable: true, type: "datetime", comment: "วันเกิด", default: null, }) birthDate: Date; @Column({ nullable: true, comment: "เหตุผลกรณีวันไม่ตรงกัน", length: 255, default: null, }) reasonSameDate: string; @Column({ nullable: true, comment: "เชื้อชาติ", length: 255, default: null, }) ethnicity: string; @Column({ nullable: true, comment: "เบอร์โทร", length: 255, default: null, }) telephoneNumber: string; @Column({ nullable: true, comment: "สัญชาติ", length: 255, default: null, }) nationality: string; @Column({ nullable: true, comment: "เพศ", length: 40, default: null, }) gender: string; @Column({ nullable: true, comment: "ความสัมพันธ์", length: 40, default: null, }) relationship: string; @Column({ nullable: true, comment: "ศาสนา", length: 255, default: null, }) religion: string; @Column({ nullable: true, comment: "กรุ๊ปเลือด", length: 40, default: null, }) bloodGroup: string; @Column({ comment: "เงินเดือนฐาน", default: 0, nullable: true, type: "double", }) amount: Double; @Column({ comment: "เงินพิเศษ", default: 0, nullable: true, type: "double", }) amountSpecial: Double; @Column({ comment: "เงินประจำตำแหน่ง", default: 0, nullable: true, type: "double", }) positionSalaryAmount: Double; @Column({ comment: "เงินค่าตอบแทนรายเดือน", default: 0, nullable: true, type: "double", }) mouthSalaryAmount: Double; @Column({ nullable: true, length: 40, comment: "ไอดีคำสั่งพ้นจากราชการ", default: null, }) leaveCommandId: string; @Column({ nullable: true, length: 255, comment: "เลขที่คำสั่งพ้นจากราชการ", default: null, }) leaveCommandNo: string; @Column({ nullable: true, comment: "หมายเหตุแนวตั้งคำสั่งพ้นจากราชการ", type: "text", default: null, }) leaveRemark: string; @Column({ nullable: true, type: "datetime", comment: "วันที่ลงนามคำสั่งพ้นจากราชการ", default: null, }) leaveDate: Date | null; @Column({ nullable: true, type: "text", comment: "ประเภทพ้นคำสั่งพ้นจากราชการ", default: null, }) leaveType: string; @Column({ comment: "สถานะการตรวจสอบ", length: 40, default: "PENDING", }) statusCheckEdit: string; @Column({ comment: "สถานะยืนยัน privacyCheckin", default: false, }) privacyCheckin: boolean; @Column({ comment: "สถานะยืนยัน privacyUser", default: false, }) privacyUser: boolean; @Column({ comment: "สถานะยืนยัน privacyMgt", default: false, }) privacyMgt: boolean; @OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder) current_holders: PosMaster[]; @OneToMany(() => PosMaster, (posMaster) => posMaster.next_holder) next_holders: PosMaster[]; @OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.profile) profileSalary: ProfileSalary[]; @OneToMany(() => ProfileSalaryTemp, (profileSalaryTemp) => profileSalaryTemp.profile) profileSalaryTemp: ProfileSalaryTemp[]; @OneToMany(() => ProfileDiscipline, (profileDiscipline) => profileDiscipline.profile) profileDisciplines: ProfileDiscipline[]; @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(() => ProfileActposition, (profileActposition) => profileActposition.profile) profileActpositions: ProfileActposition[]; @OneToMany(() => ProfileAssistance, (profileAssistance) => profileAssistance.profile) profileAssistances: ProfileAssistance[]; @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[]; @OneToMany(() => ProfileDevelopment, (profileDevelopment) => profileDevelopment.profile) profileDevelopments: ProfileDevelopment[]; @OneToMany(() => DevelopmentRequest, (developmentRequest) => developmentRequest.profile) developmentRequests: DevelopmentRequest[]; @OneToMany(() => ProfileAvatar, (profileAvatar) => profileAvatar.profile) profileAvatars: ProfileAvatar[]; @OneToMany(() => ProfileEdit, (profileEdit) => profileEdit.profile) profileEdits: ProfileEdit[]; @OneToMany(() => ProfileFamilyHistory, (profileFamily) => profileFamily.profile) profileFamily: ProfileFamilyHistory[]; @OneToMany(() => ProfileChildren, (profileChildren) => profileChildren.profile) profileChildrens: ProfileChildren[]; @OneToMany(() => ProfileGovernment, (profileGovernment) => profileGovernment.profile) profileGovernment: ProfileGovernment[]; @OneToMany(() => ProfileHistory, (v) => v.profile) histories: ProfileHistory[]; @OneToMany(() => ProfileFamilyFather, (v) => v.profile) profileFamilyFather: ProfileFamilyFather[]; @OneToMany(() => ProfileFamilyMother, (v) => v.profile) profileFamilyMother: ProfileFamilyMother[]; @OneToMany(() => ProfileFamilyCouple, (v) => v.profile) profileFamilyCouple: ProfileFamilyCouple[]; @OneToMany(() => CommandSend, (v) => v.profile) commandSends: CommandSend[]; @OneToMany(() => CommandSign, (v) => v.profile) commandSigns: CommandSign[]; @OneToMany(() => StateOperatorUser, (v) => v.profile) stateOperatorUsers: StateOperatorUser[]; @OneToMany(() => StateUserComment, (v) => v.profile) stateUserComments: StateUserComment[]; @OneToMany(() => PositionSalaryEditHistory, (v) => v.profile) positionSalaryEditHistory: PositionSalaryEditHistory[]; @OneToMany(() => ProfileChangeName, (v) => v.profile) profileChangeNames: ProfileChangeName[]; @OneToMany(() => ProfileAbsentLate, (v) => v.profile) profileAbsentLates: ProfileAbsentLate[]; @ManyToOne(() => PosLevel, (posLevel) => posLevel.profiles) @JoinColumn({ name: "posLevelId" }) posLevel: PosLevel; @ManyToOne(() => PosType, (posType) => posType.profiles) @JoinColumn({ name: "posTypeId" }) posType: PosType; // calculateRetireYear(): number { // return calculateRetireYear(this.birthDate); // } @Column({ nullable: true, comment: "ที่อยู่ตามทะเบียนบ้าน", default: null, length: 255, }) registrationAddress: string; @Column({ nullable: true, comment: "จังหวัดตามทะเบียนบ้าน", length: 255, default: null, }) registrationProvinceId: string; @ManyToOne(() => Province, (v) => v.registrationProvinces) registrationProvince: Province; @Column({ nullable: true, comment: "เขตตามทะเบียนบ้าน", length: 255, default: null, }) registrationDistrictId: string; @ManyToOne(() => District, (v) => v.registrationDistricts) registrationDistrict: District; @Column({ nullable: true, comment: "แขวงตามทะเบียนบ้าน", length: 255, default: null, }) registrationSubDistrictId: string; @ManyToOne(() => SubDistrict, (v) => v.registrationSubDistricts) registrationSubDistrict: SubDistrict; @Column({ nullable: true, comment: "รหัสไปรษณีย์ตามทะเบียนบ้าน", default: null, length: 5, }) registrationZipCode: string; @Column({ nullable: true, comment: "ที่อยู่ตามปัจจุบัน", default: null, length: 255, }) currentAddress: string; @Column({ nullable: true, comment: "จังหวัดตามปัจจุบัน", length: 255, default: null, }) currentProvinceId: string; @ManyToOne(() => Province, (v) => v.currentProvinces) currentProvince: Province; @Column({ nullable: true, comment: "เขตตามปัจจุบัน", length: 255, default: null, }) currentDistrictId: string; @ManyToOne(() => District, (v) => v.currentDistricts) currentDistrict: District; @Column({ nullable: true, comment: "แขวงตามปัจจุบัน", length: 255, default: null, }) currentSubDistrictId: string; @ManyToOne(() => SubDistrict, (v) => v.currentSubDistricts) currentSubDistrict: SubDistrict; @Column({ nullable: true, comment: "รหัสไปรษณีย์ตามปัจจุบัน", default: null, length: 5, }) currentZipCode: string; @Column({ nullable: true, length: 40, comment: "ไอดีรอบลงเวลาล่าสุด", }) dutyTimeId: string; @Column({ nullable: true, type: "datetime", comment: "รอบลงเวลาล่าสุด", default: null, }) dutyTimeEffectiveDate: Date; @OneToMany(() => PermissionOrg, (permissionOrg) => permissionOrg.profileTree) permissionProfiles: PermissionOrg[]; @ManyToMany(() => RoleKeycloak, (roleKeycloak) => roleKeycloak.profiles) @JoinTable() roleKeycloaks: RoleKeycloak[]; } @Entity("profileHistory") export class ProfileHistory extends Profile { @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ProfileInformation", default: null, }) profileId: string; @Column({ nullable: true, type: "datetime", comment: "วันเกิดเดิม โดยจะบันทึกเมื่อมีการแก้ไขข้อมูลส่วนตัว", default: null, }) birthDateOld: Date; @ManyToOne(() => Profile, (v) => v.histories, { onDelete: "CASCADE" }) profile: Profile; } @Entity("profileAddressHistory") export class ProfileAddressHistory extends EntityBase { @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ProfileInformation", default: null, }) profileId: string; @Column({ nullable: true, comment: "ที่อยู่ตามทะเบียนบ้าน", default: null, length: 255, }) registrationAddress: string; @Column({ nullable: true, comment: "จังหวัดตามทะเบียนบ้าน", length: 255, default: null, }) registrationProvinceId: string; @ManyToOne(() => Province, (v) => v.registrationProvinces) registrationProvince: Province; @Column({ nullable: true, comment: "เขตตามทะเบียนบ้าน", length: 255, default: null, }) registrationDistrictId: string; @ManyToOne(() => District, (v) => v.registrationDistricts) registrationDistrict: District; @Column({ nullable: true, comment: "แขวงตามทะเบียนบ้าน", length: 255, default: null, }) registrationSubDistrictId: string; @ManyToOne(() => SubDistrict, (v) => v.registrationSubDistricts) registrationSubDistrict: SubDistrict; @Column({ nullable: true, comment: "รหัสไปรษณีย์ตามทะเบียนบ้าน", default: null, length: 5, }) registrationZipCode: string; @Column({ nullable: true, comment: "ที่อยู่ตามปัจจุบัน", default: null, length: 255, }) currentAddress: string; @Column({ nullable: true, comment: "จังหวัดตามปัจจุบัน", length: 255, default: null, }) currentProvinceId: string; @ManyToOne(() => Province, (v) => v.currentProvinces) currentProvince: Province; @Column({ nullable: true, comment: "เขตตามปัจจุบัน", length: 255, default: null, }) currentDistrictId: string; @ManyToOne(() => District, (v) => v.currentDistricts) currentDistrict: District; @Column({ nullable: true, comment: "แขวงตามปัจจุบัน", length: 255, default: null, }) currentSubDistrictId: string; @ManyToOne(() => SubDistrict, (v) => v.currentSubDistricts) currentSubDistrict: SubDistrict; @Column({ nullable: true, comment: "รหัสไปรษณีย์ตามปัจจุบัน", default: null, length: 5, }) currentZipCode: string; @ManyToOne(() => Profile, (v) => v.histories, { onDelete: "CASCADE" }) profile: Profile; @Column({ nullable: true, length: 40, comment: "คีย์นอก(FK)ของตาราง ProfileEmployee", default: null, }) profileEmployeeId: string; @ManyToOne(() => ProfileEmployee, (ProfileEmployee) => ProfileEmployee.profileAddressHistories) @JoinColumn({ name: "profileEmployeeId" }) profileEmployee: ProfileEmployee; } export class CreateProfile { rank: string; prefix: string; firstName: string; lastName: string; position: string; // email: string | null; // phone: string | null; // isProbation: boolean | null; // dateRetire: Date | null; birthDate: Date | null; // ethnicity: string | null; // telephoneNumber: string | null; // nationality: string | null; citizenId: string; // religion: string | null; posLevelId: string | null; posTypeId: string | null; // gender: string | null; // relationship: string | null; // bloodGroup: string | null; } export class CreateProfileAllFields { id?: string | null; rank: string | null; prefix: string; firstName: string; lastName: string; citizenId: string; position: string | null; posLevelId: string | null; posTypeId: string | null; email: string | null; phone: string | null; keycloak: string | null; isProbation: boolean | null; isLeave: boolean | null; dateRetire: Date | null; dateAppoint: Date | null; dateStart: Date | null; govAgeAbsent: number | null; govAgePlus: number | null; birthDate: Date | null; reasonSameDate: Date | null; ethnicity: string | null; telephoneNumber: string | null; nationality: string | null; gender: string | null; relationship: string | null; religion: string | null; bloodGroup: string | null; registrationAddress: string | null; registrationProvinceId: string | null; registrationDistrictId: string | null; registrationSubDistrictId: string | null; registrationZipCode: string | null; currentAddress: string | null; currentProvinceId: string | null; currentDistrictId: string | null; currentSubDistrictId: string | null; currentZipCode: string | null; amount?: Double | null; amountSpecial?: Double | null; objectRefId?: string | null; } export type UpdateProfile = { rank?: string | null; 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; telephoneNumber?: string | null; nationality?: string | null; citizenId?: string | null; religion: string | null; posLevelId?: string | null; posTypeId?: string | null; gender?: string | null; relationship?: string | null; bloodGroup?: string | null; prefixMain?: string | null; }; export type UpdateProfileReqEdit = { rank?: string | null; prefix?: string | null; firstName?: string | null; lastName?: string | null; birthDate?: Date | null; ethnicity?: string | null; telephoneNumber?: string | null; nationality?: string | null; religion?: string | null; gender?: string | null; relationship?: string | null; bloodGroup?: string | null; registrationAddress?: string | null; registrationProvinceId?: string | null; registrationDistrictId?: string | null; registrationSubDistrictId?: string | null; registrationZipCode?: string | null; }; export type UpdateProfileFather = { fatherPrefix?: string | null; fatherFirstName?: string | null; fatherLastName?: string | null; fatherCareer?: string | null; fatherLive?: boolean | null; fatherCitizenId?: string | null; }; export type UpdateProfileMother = { motherPrefix?: string | null; motherFirstName?: string | null; motherLastName?: string | null; motherCareer?: string | null; motherLive?: boolean | null; motherCitizenId?: string | null; }; export type UpdateProfileCouple = { couplePrefix?: string | null; coupleFirstName?: string | null; coupleLastName?: string | null; coupleLastNameOld?: string | null; coupleCareer?: string | null; coupleLive?: boolean | null; relationship?: string | null; coupleCitizenId?: string | null; }; export type UpdateProfileAddress = { registrationAddress?: string | null; registrationProvinceId?: string | null; registrationDistrictId?: string | null; registrationSubDistrictId?: string | null; registrationZipCode?: string | null; currentAddress?: string | null; currentProvinceId?: string | null; currentDistrictId?: string | null; currentSubDistrictId?: string | null; currentZipCode?: string | null; }; export class UpdatePrivacyDto { system: string; accept: boolean; }