From ffb9ea327ddce6df35ae5dd980fa9ed1efbf525a Mon Sep 17 00:00:00 2001 From: Bright Date: Tue, 22 Jul 2025 11:25:45 +0700 Subject: [PATCH] =?UTF-8?q?Fix=20=E0=B8=A3=E0=B8=B0=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=97=E0=B8=B0=E0=B9=80=E0=B8=9A=E0=B8=B5=E0=B8=A2=E0=B8=99?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=A7=E0=B8=B1=E0=B8=95=E0=B8=B4?= =?UTF-8?q?=20(=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=E0=B8=8A=E0=B8=B1=E0=B9=88=E0=B8=A7=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A7)=20>>=20=E0=B8=84=E0=B9=89=E0=B8=99=E0=B8=AB?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=B2=E0=B8=A2=E0=B8=8A=E0=B8=B7=E0=B9=88?= =?UTF-8?q?=E0=B8=AD=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=E0=B8=8A=E0=B8=B1=E0=B9=88=E0=B8=A7=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=B2=E0=B8=A7=20#1647?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProfileEmployeeTempController.ts | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index ceef5d26..1aed8a50 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1589,31 +1589,37 @@ export class ProfileEmployeeTempController extends Controller { keyword2: `${posLevel}`, }, ) - // .andWhere( - // isProbation != undefined && isProbation != null - // ? `profileEmployee.isProbation = ${isProbation}` - // : "1=1", - // ) - // .andWhere( - // isRetire != undefined && isRetire != null - // ? isRetire == true - // ? `profileEmployee.dateRetire IS null` - // : `profileEmployee.dateRetire IS NOT NULL` - // : "1=1", - // ) .andWhere( "profileEmployee.employeeClass = :type", { type: type ? type.trim().toLocaleUpperCase() : "TEMP" } ) .orWhere( - `current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND - current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND - current_holderTemps.orgChild4Id is null AND profileEmployee.createdUserId = :keycloak AND - profileEmployee.employeeClass = :type`, { - keycloak: request.user.sub, - type: type ? type.trim().toLocaleUpperCase() : "TEMP", - } + new Brackets((qb) => { + if (!searchKeyword) { + qb.andWhere( + `current_holderTemps.orgRootId is null AND current_holderTemps.orgChild1Id is null AND + current_holderTemps.orgChild2Id is null AND current_holderTemps.orgChild3Id is null AND + current_holderTemps.orgChild4Id is null AND profileEmployee.createdUserId = :keycloak AND + profileEmployee.employeeClass = :type + `, + { + keycloak: request.user.sub, + type: type ? type.trim().toLocaleUpperCase() : "TEMP" + } + ) + } + else { + qb.andWhere( + searchKeyword != undefined && searchKeyword != null && searchKeyword != "" + ? queryLike + : "1=1", + { + keyword: `%${searchKeyword}%`, + }, + ) + } + }), ) .skip((page - 1) * pageSize) .take(pageSize)