From e7775516571239990c70addd9be46f171ca65ecc Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Mon, 15 Jul 2024 11:41:20 +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=9F=E0=B8=B4=E0=B8=A7=20API?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KpiUserEvaluationController.ts | 56 ++++++++++++++----- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 3049e29..4121349 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -250,6 +250,18 @@ export class KpiUserEvaluationController extends Controller { }) .orWhere("kpiUserEvaluation.lastName LIKE :keyword", { keyword: `%${requestBody.keyword}%`, + }) + .orWhere("kpiUserEvaluation.org LIKE :keyword", { + keyword: `%${requestBody.keyword}%`, + }) + .orWhere("kpiUserEvaluation.position LIKE :keyword", { + keyword: `%${requestBody.keyword}%`, + }) + .orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", { + keyword: `%${requestBody.keyword}%`, + }) + .orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", { + keyword: `%${requestBody.keyword}%`, }); }), ) @@ -258,20 +270,36 @@ export class KpiUserEvaluationController extends Controller { .take(requestBody.pageSize) .getManyAndCount(); - const mapData = kpiUserEvaluation.map((item) => ({ - id: item.id, - profileId: item.profileId, - prefix: item.prefix, - firstname: item.firstName, - lastname: item.lastName, - kpiPeriodId: item.kpiPeriodId, - evaluationStatus: item.evaluationStatus, - evaluationResults: item.evaluationResults, - createdAt: item.createdAt, - evaluatorId: item.evaluatorId, - commanderId: item.commanderId, - commanderHighId: item.commanderHighId, - })); + const mapData = kpiUserEvaluation.map((item) => { + const fullNameParts = [item.child4, item.child3, item.child2, item.child1, item.org]; + + const organization = fullNameParts + .filter((part) => part !== undefined && part !== null) + .join("/"); + + return { + id: item.id, + profileId: item.profileId, + prefix: item.prefix, + firstname: item.firstName, + lastname: item.lastName, + kpiPeriodId: item.kpiPeriodId, + evaluationStatus: item.evaluationStatus, + evaluationResults: item.evaluationResults, + createdAt: item.createdAt, + evaluatorId: item.evaluatorId, + commanderId: item.commanderId, + commanderHighId: item.commanderHighId, + root: item.org, + rootId: item.orgId, + position: item.position, + // posTypeId: item.posTypeId, + posTypeName: item.posTypeName, + // posLevelId: item.posLevelId, + posLevelName: item.posLevelName, + organization: organization, + }; + }); return new HttpSuccess({ data: mapData, total }); }