From 09f0918482261a93e6943ee607e7b21c1dbec04e Mon Sep 17 00:00:00 2001 From: kittapath Date: Fri, 17 Jan 2025 10:27:16 +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=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/EmployeePositionController.ts | 67 +++++++++++-------- 1 file changed, 38 insertions(+), 29 deletions(-) diff --git a/src/controllers/EmployeePositionController.ts b/src/controllers/EmployeePositionController.ts index 6fe61849..59377d32 100644 --- a/src/controllers/EmployeePositionController.ts +++ b/src/controllers/EmployeePositionController.ts @@ -291,14 +291,14 @@ export class EmployeePositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", - posType:{ + posType: { posTypeRank: "ASC", - createdAt: "DESC" + createdAt: "DESC", }, - posLevel: { + posLevel: { posLevelName: "ASC", - createdAt: "DESC" - } + createdAt: "DESC", + }, }, }); break; @@ -314,14 +314,14 @@ export class EmployeePositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", - posType:{ + posType: { posTypeRank: "ASC", - createdAt: "DESC" + createdAt: "DESC", }, - posLevel: { + posLevel: { posLevelName: "ASC", - createdAt: "DESC" - } + createdAt: "DESC", + }, }, }); break; @@ -329,10 +329,9 @@ export class EmployeePositionController extends Controller { case "positionLevel": if (!isNaN(Number(keyword))) { let findEmpLevels; - if(Number(keyword) === 0) { + if (Number(keyword) === 0) { findEmpLevels = await this.employeePosLevelRepository.find(); - } - else { + } else { findEmpLevels = await this.employeePosLevelRepository.find({ where: { posLevelName: Number(keyword) }, }); @@ -343,14 +342,14 @@ export class EmployeePositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", - posType:{ + posType: { posTypeRank: "ASC", - createdAt: "DESC" + createdAt: "DESC", }, - posLevel: { + posLevel: { posLevelName: "ASC", - createdAt: "DESC" - } + createdAt: "DESC", + }, }, }); } else { @@ -360,14 +359,14 @@ export class EmployeePositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", - posType:{ + posType: { posTypeRank: "ASC", - createdAt: "DESC" + createdAt: "DESC", }, - posLevel: { + posLevel: { posLevelName: "ASC", - createdAt: "DESC" - } + createdAt: "DESC", + }, }, }); } @@ -379,14 +378,14 @@ export class EmployeePositionController extends Controller { order: { posDictName: "ASC", createdAt: "DESC", - posType:{ + posType: { posTypeRank: "ASC", - createdAt: "DESC" + createdAt: "DESC", }, - posLevel: { + posLevel: { posLevelName: "ASC", - createdAt: "DESC" - } + createdAt: "DESC", + }, }, }); break; @@ -417,7 +416,7 @@ export class EmployeePositionController extends Controller { posLevelName: `${posTypeShortName} ${posLevelName}`, createdAt: item.createdAt, lastUpdatedAt: item.lastUpdatedAt, - lastUpdateFullName: item.lastUpdateFullName + lastUpdateFullName: item.lastUpdateFullName, }; }), ); @@ -2196,6 +2195,16 @@ export class EmployeePositionController extends Controller { dataMaster.positions.forEach(async (position) => { if (position.id === requestBody.position) { position.positionIsSelected = true; + const profile = await this.profileRepository.findOne({ + where: { id: requestBody.profileId }, + }); + if (profile != null) { + const _null: any = null; + profile.posLevelId = position?.posLevelId ?? _null; + profile.posTypeId = position?.posTypeId ?? _null; + profile.position = position?.positionName ?? _null; + await this.profileRepository.save(profile); + } } else { position.positionIsSelected = false; }