From a83e1f111bcbacaf078f187cb3494221d86c568c Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 13 Sep 2024 15:23:19 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9?= =?UTF-8?q?=E0=B8=A5=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=9B=E0=B8=A3=E0=B8=B0?= =?UTF-8?q?=E0=B9=80=E0=B8=A1=E0=B8=B4=E0=B8=99>>=E0=B8=AA=E0=B8=A1?= =?UTF-8?q?=E0=B8=A3=E0=B8=A3=E0=B8=96=E0=B8=99=E0=B8=B0=20(=E0=B8=9A?= =?UTF-8?q?=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6=E0=B8=81=E0=B8=82=E0=B9=89?= =?UTF-8?q?=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5=E0=B8=95=E0=B8=B3=E0=B9=81?= =?UTF-8?q?=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87=20=E0=B9=81=E0=B8=95?= =?UTF-8?q?=E0=B9=88=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=E0=B8=95=E0=B8=B3=E0=B9=81=E0=B8=AB=E0=B8=99=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B9=84=E0=B8=A1=E0=B9=88=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= =?UTF-8?q?)=20#593?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/KpiLinkController.ts | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/controllers/KpiLinkController.ts b/src/controllers/KpiLinkController.ts index 4e0035e..72b45b5 100644 --- a/src/controllers/KpiLinkController.ts +++ b/src/controllers/KpiLinkController.ts @@ -136,10 +136,23 @@ export class kpiLinkController extends Controller { ...requestBody, kpiCapacitys: [], }); + + const chkCapacity = await this.kpiCapacityRepository.find({ + where: { + id: In(requestBody.kpiCapacityIds), + }, + }); + if (!chkCapacity) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการเชื่อมโยง"); + } + + chkKpiLink.kpiCapacitys = chkCapacity; chkKpiLink.kpiGroupId = requestBody.kpiGroupId; chkKpiLink.lastUpdateUserId = request.user.sub; chkKpiLink.lastUpdateFullName = request.user.name; chkKpiLink.lastUpdatedAt = new Date(); + await this.kpiLinkRepository.save(chkKpiLink); + setLogDataDiff(request, { before, after: chkKpiLink }); if (requestBody.positions != null) { await Promise.all( @@ -159,19 +172,6 @@ export class kpiLinkController extends Controller { ); } - const chkCapacity = await this.kpiCapacityRepository.find({ - where: { - id: In(requestBody.kpiCapacityIds), - }, - }); - if (!chkCapacity) { - throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลการเชื่อมโยง"); - } - chkKpiLink.kpiCapacitys = chkCapacity; - - await this.kpiLinkRepository.save(chkKpiLink, { data: request }); - setLogDataDiff(request, { before, after: chkKpiLink }); - return new HttpSuccess(chkKpiLink.id); }