From fec583d13169859526b72fd440e8056ee1495978 Mon Sep 17 00:00:00 2001 From: Bright Date: Thu, 9 May 2024 10:59:49 +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=20year,=20durationKPI?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../KpiUserEvaluationController.ts | 44 +++++++++++-------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 3b2032b..7490744 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -240,25 +240,8 @@ export class KpiUserEvaluationController extends Controller { @Get("{id}") async GetKpiUserEvaluationById(@Path() id: string) { const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ + relations:["kpiPeriod"], where: { id: id }, - select: [ - "id", - "profileId", - "prefix", - "firstName", - "lastName", - "kpiPeriodId", - "evaluationStatus", - "evaluationResults", - "createdAt", - "evaluatorId", - "commanderId", - "commanderHighId", - "plannedPoint", - "rolePoint", - "specialPoint", - "capacityPoint", - ], }); if (!kpiUserEvaluation) { throw new HttpError( @@ -266,7 +249,27 @@ export class KpiUserEvaluationController extends Controller { "ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้", ); } - return new HttpSuccess(kpiUserEvaluation); + const mapData = { + id: kpiUserEvaluation.id, + profileId: kpiUserEvaluation.profileId, + prefix: kpiUserEvaluation.prefix, + firstName: kpiUserEvaluation.firstName, + lastName: kpiUserEvaluation.lastName, + evaluationStatus: kpiUserEvaluation.evaluationStatus, + evaluationResults: kpiUserEvaluation.evaluationResults, + createdAt: kpiUserEvaluation.createdAt, + evaluatorId: kpiUserEvaluation.evaluatorId, + commanderId: kpiUserEvaluation.commanderId, + commanderHighId: kpiUserEvaluation.commanderHighId, + plannedPoint: kpiUserEvaluation.plannedPoint, + rolePoint: kpiUserEvaluation.rolePoint, + specialPoint: kpiUserEvaluation.specialPoint, + capacityPoint: kpiUserEvaluation.capacityPoint, + kpiPeriodId: kpiUserEvaluation.kpiPeriodId, + year: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.year, + durationKPI: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.durationKPI, + } + return new HttpSuccess(mapData); } /** @@ -286,6 +289,7 @@ export class KpiUserEvaluationController extends Controller { ) { const [kpiUserEvaluation, total] = await AppDataSource.getRepository(KpiUserEvaluation) .createQueryBuilder("kpiUserEvaluation") + .leftJoinAndSelect("kpiUserEvaluation.kpiPeriod", "kpiPeriod") .andWhere(kpiPeriodId ? "kpiPeriodId LIKE :kpiPeriodId" : "1=1", { kpiPeriodId: kpiPeriodId, }) @@ -318,6 +322,8 @@ export class KpiUserEvaluationController extends Controller { rolePoint: item.rolePoint, specialPoint: item.specialPoint, capacityPoint: item.capacityPoint, + year: item.kpiPeriod ? item.kpiPeriod.year : null, + durationKPI: item.kpiPeriod ? item.kpiPeriod.durationKPI : null, })); return new HttpSuccess({ data: mapData, total }); }