From 7fbc14e81854613f910f27940815e85a470a9c08 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Thu, 9 May 2024 12:52:35 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=20user=20=E0=B9=80=E0=B8=81?= =?UTF-8?q?=E0=B8=B5=E0=B9=88=E0=B8=A2=E0=B8=A7=E0=B8=82=E0=B9=89=E0=B8=AD?= =?UTF-8?q?=E0=B8=87=E0=B8=81=E0=B8=B1=E0=B8=9A=E0=B9=81=E0=B8=9A=E0=B8=9A?= =?UTF-8?q?=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KpiUserEvaluationController.ts | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 460a456..374b68c 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -53,16 +53,39 @@ export class KpiUserEvaluationController extends Controller { */ @Get("admin") async listKpiAdminEvaluation( + @Request() request: { user: Record }, @Query("page") page: number = 1, @Query("pageSize") pageSize: number = 10, @Query("kpiPeriodId") kpiPeriodId?: string, @Query("keyword") keyword?: string, ) { + let profileId: any = null; + await new CallAPI() + .GetData(request, "org/profile/keycloak/position") + .then((x) => { + profileId = x.profileId; + }) + .catch((x) => { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลในทะเบียนประวัติ"); + }); const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") .andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: kpiPeriodId, }) + .andWhere( + new Brackets((qb) => { + qb.orWhere("kpiUserEvaluation.evaluatorId LIKE :profileId", { + profileId: `%${profileId}%`, + }) + .orWhere("kpiUserEvaluation.commanderId LIKE :profileId", { + profileId: `%${profileId}%`, + }) + .orWhere("kpiUserEvaluation.commanderHighId LIKE :profileId", { + profileId: `%${profileId}%`, + }); + }), + ) .andWhere( new Brackets((qb) => { qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", { keyword: `%${keyword}%` })