From 29a574035e2767d05b2ba5fe0abc324e80e7b5b2 Mon Sep 17 00:00:00 2001 From: kittapath Date: Tue, 29 Oct 2024 12:23:37 +0700 Subject: [PATCH] no message --- src/controllers/CommandController.ts | 41 ++++++++++++++++----------- src/controllers/WorkflowController.ts | 1 - 2 files changed, 25 insertions(+), 17 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index e836ad41..58348b38 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -1840,7 +1840,7 @@ export class CommandController extends Controller { profile.posLevelId = _null; } const returnWork = await checkReturnCommandType(String(item.commandId)); - if(returnWork && item.isGovernment) { + if (returnWork && item.isGovernment) { const userKeycloakId = await createUser(profile.citizenId, profile.citizenId, { firstName: profile.firstName, lastName: profile.lastName, @@ -2204,26 +2204,32 @@ export class CommandController extends Controller { // ทะเบียนประวัติ if (item.isLeave != null) { + const _profile = await this.profileRepository.findOne({ + where: { id: item.profileId }, + }); + if (!_profile) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้"); + } const _null: any = null; - profile.isLeave = item.isLeave; - profile.leaveReason = item.leaveReason ?? _null; - profile.dateLeave = item.dateLeave ?? _null; - profile.lastUpdateUserId = req.user.sub; - profile.lastUpdateFullName = req.user.name; - profile.lastUpdatedAt = new Date(); + _profile.isLeave = item.isLeave; + _profile.leaveReason = item.leaveReason ?? _null; + _profile.dateLeave = item.dateLeave ?? _null; + _profile.lastUpdateUserId = req.user.sub; + _profile.lastUpdateFullName = req.user.name; + _profile.lastUpdatedAt = new Date(); const exceptClear = await checkExceptCommandType(String(item.commandId)); if (item.isLeave == true && !exceptClear) { - await removeProfileInOrganize(profile.id, "OFFICER"); + await removeProfileInOrganize(_profile.id, "OFFICER"); } const clearProfile = await checkCommandType(String(item.commandId)); if (clearProfile) { - if (profile.keycloak != null) { - const delUserKeycloak = await deleteUser(profile.keycloak); - if (delUserKeycloak) profile.keycloak = _null; + if (_profile.keycloak != null) { + const delUserKeycloak = await deleteUser(_profile.keycloak); + if (delUserKeycloak) _profile.keycloak = _null; } - profile.position = _null; - profile.posTypeId = _null; - profile.posLevelId = _null; + _profile.position = _null; + _profile.posTypeId = _null; + _profile.posLevelId = _null; } await this.profileRepository.save(profile); } @@ -2870,7 +2876,7 @@ export class CommandController extends Controller { RemarkHorizontal?: any | null; RemarkVertical?: any | null; CommandYear?: any | null; - }[]; + }[]; }, ) { let data: any = []; @@ -2933,7 +2939,10 @@ export class CommandController extends Controller { "" + posMasterAct.posMasterChild?.current_holder?.firstName ?? "" + " " + posMasterAct.posMasterChild?.current_holder?.lastName ?? null, - oc: (posMasterAct.posMasterChild?.current_holder?.position ?? "-") + "/" + (_organization ?? "-"), + oc: + (posMasterAct.posMasterChild?.current_holder?.position ?? "-") + + "/" + + (_organization ?? "-"), postype: posMasterAct.posMasterChild?.current_holder?.posType?.posTypeName ?? "-", poslevel: posMasterAct.posMasterChild?.current_holder?.posLevel?.posLevelName ?? "-", organizationNew: _organizationNew ?? "-", diff --git a/src/controllers/WorkflowController.ts b/src/controllers/WorkflowController.ts index 01aa51f1..8e2e193e 100644 --- a/src/controllers/WorkflowController.ts +++ b/src/controllers/WorkflowController.ts @@ -175,7 +175,6 @@ export class WorkflowController extends Controller { receiverUserId: x.profileId, notiLink: "", })); - console.log(profileNow); await new CallAPI() .PostData(req, "/placement/noti/profiles", { subject: `รายการถูกส่ง`,