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)