From c41b0f008a005b351df4b8269cbe8ef9ddf63265 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Fri, 8 Mar 2024 14:54:24 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1?= =?UTF-8?q?=E0=B8=9F=E0=B8=B4=E0=B8=A7=E0=B8=A7=E0=B8=B4=E0=B8=99=E0=B8=B1?= =?UTF-8?q?=E0=B8=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OrganizationUnauthorizeController.ts | 5 ++-- src/controllers/ProfileController.ts | 5 ++-- src/entities/Profile.ts | 14 ++++++++++- src/entities/ProfileDiscipline.ts | 25 +++++++++++++++++++ 4 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 src/entities/ProfileDiscipline.ts diff --git a/src/controllers/OrganizationUnauthorizeController.ts b/src/controllers/OrganizationUnauthorizeController.ts index 1828bbdc..2445ff83 100644 --- a/src/controllers/OrganizationUnauthorizeController.ts +++ b/src/controllers/OrganizationUnauthorizeController.ts @@ -69,6 +69,7 @@ export class OrganizationUnauthorizeController extends Controller { .leftJoinAndSelect("posMaster.positions", "positions") .leftJoinAndSelect("positions.posExecutive", "posExecutive") .leftJoinAndSelect("current_holder.profileSalary", "profileSalary") + .leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") .where({ @@ -199,8 +200,8 @@ export class OrganizationUnauthorizeController extends Controller { child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null, result: null, duration: null, - isPunish: false, - isSuspension: false, + isPunish: item.current_holder.profileDiscipline.length > 0 ? true : false, + isSuspension: item.current_holder == null ? false : true, isAbsent: false, isLeave: false, isRetired: false, diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 478cdf0e..f1f3db6c 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -930,6 +930,7 @@ export class ProfileController extends Controller { .leftJoinAndSelect("posMaster.positions", "positions") .leftJoinAndSelect("positions.posExecutive", "posExecutive") .leftJoinAndSelect("current_holder.profileSalary", "profileSalary") + .leftJoinAndSelect("current_holder.profileDiscipline", "profileDiscipline") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") .where((qb) => { @@ -1066,8 +1067,8 @@ export class ProfileController extends Controller { child4: item.orgChild4?.orgChild4Name ? item.orgChild4.orgChild4Name : null, result: null, duration: null, - isPunish: false, - isSuspension: false, + isPunish: item.current_holder.profileDiscipline.length > 0 ? true : false, + isSuspension: item.current_holder.dateRetire == null ? false : true, isAbsent: false, isLeave: false, isRetired: false, diff --git a/src/entities/Profile.ts b/src/entities/Profile.ts index b6c8e358..ed1df480 100644 --- a/src/entities/Profile.ts +++ b/src/entities/Profile.ts @@ -4,6 +4,7 @@ import { PosMaster } from "./PosMaster"; import { PosLevel } from "./PosLevel"; import { PosType } from "./PosType"; import { ProfileSalary } from "./ProfileSalary"; +import { ProfileDiscipline } from "./ProfileDiscipline"; @Entity("profile") export class Profile extends EntityBase { @@ -108,6 +109,14 @@ export class Profile extends EntityBase { }) isProbation: boolean; + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่พักราชการ", + default: null, + }) + dateRetire: Date; + @OneToMany(() => PosMaster, (posMaster) => posMaster.current_holder) current_holders: PosMaster[]; @@ -115,7 +124,10 @@ export class Profile extends EntityBase { next_holders: PosMaster[]; @OneToMany(() => ProfileSalary, (profileSalary) => profileSalary.profile) - profileSalary: ProfileSalary[]; + profileSalary: ProfileSalary[]; + + @OneToMany(() => ProfileDiscipline, (profileDiscipline) => profileDiscipline.profile) + profileDiscipline: ProfileDiscipline[]; @ManyToOne(() => PosLevel, (posLevel) => posLevel.posLevels) @JoinColumn({ name: "posLevelId" }) diff --git a/src/entities/ProfileDiscipline.ts b/src/entities/ProfileDiscipline.ts new file mode 100644 index 00000000..810d9cfe --- /dev/null +++ b/src/entities/ProfileDiscipline.ts @@ -0,0 +1,25 @@ +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; +import { EntityBase } from "./base/Base"; +import { Profile } from "./Profile"; + +@Entity("profileDiscipline") +export class ProfileDiscipline extends EntityBase { + @Column({ + nullable: true, + type: "datetime", + comment: "วันที่", + default: null, + }) + date: Date; + + @Column({ + length: 40, + comment: "ไอดีโปรไฟล์", + type: "uuid", + }) + profileId: string; + + @ManyToOne(() => Profile, (profile) => profile.profileDiscipline) + @JoinColumn({ name: "profileId" }) + profile: Profile; +}