From c94d3eb54742af3eedf0640fa33a5e3a2c63f182 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 7 Mar 2024 11:00:22 +0700 Subject: [PATCH] fix --- src/controllers/ProfileController.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 2f7b1568..6e8f4adf 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -929,16 +929,15 @@ export class ProfileController extends Controller { .leftJoinAndSelect("current_holder.profileSalary", "profileSalary") .leftJoinAndSelect("current_holder.posLevel", "posLevel") .leftJoinAndSelect("current_holder.posType", "posType") - .where({ - orgRevisionId: findRevision?.id, - current_holderId: Not(IsNull()), + .where((qb) => { + if (body.rootId) { + qb.andWhere("posMaster.orgRootId = :rootId", { rootId: body.rootId }); + } + qb.andWhere("posMaster.current_holderId IS NOT NULL"); + qb.andWhere("posMaster.orgRevisionId = :orgRevisionId", { + orgRevisionId: findRevision?.id, + }); }) - .orWhere( - body.rootId == null ? "1=1" : "posMaster.orgRootId = :rootId", - { - rootId: body.rootId, - }, - ) .andWhere( new Brackets((qb) => { qb.where( @@ -997,7 +996,7 @@ export class ProfileController extends Controller { { keyword: `%${body.keyword}%`, }, - ); + ) }), ) .skip((body.page - 1) * body.pageSize)