From 0c170928d19d1f805dfa6101cbf4144a099b1bcb Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Fri, 8 Nov 2024 10:42:04 +0700 Subject: [PATCH] =?UTF-8?q?sort=20=E0=B9=80=E0=B8=A3=E0=B8=B5=E0=B8=A2?= =?UTF-8?q?=E0=B8=87=E0=B8=88=E0=B8=B2=E0=B8=81=E0=B8=A7=E0=B8=B1=E0=B8=99?= =?UTF-8?q?=E0=B8=97=E0=B8=B5=E0=B9=88=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/KpiPlanController.ts | 9 +++++++-- src/controllers/KpiUserEvaluationController.ts | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/controllers/KpiPlanController.ts b/src/controllers/KpiPlanController.ts index 630c476..87dcf68 100644 --- a/src/controllers/KpiPlanController.ts +++ b/src/controllers/KpiPlanController.ts @@ -27,6 +27,7 @@ import { KpiRole } from "../entities/kpiRole"; import permission from "../interfaces/permission"; import { RequestWithUser } from "../middlewares/user"; import { setLogDataDiff } from "../interfaces/utils"; +import { KpiUserPlanned } from "../entities/kpiUserPlanned"; @Route("api/v1/kpi/plan") @Tags("kpiPlan") @@ -39,6 +40,7 @@ import { setLogDataDiff } from "../interfaces/utils"; export class kpiPlanController extends Controller { private kpiPlanRepository = AppDataSource.getRepository(KpiPlan); private kpiRoleRepository = AppDataSource.getRepository(KpiRole); + private kpiUserPlanRepository = AppDataSource.getRepository(KpiUserPlanned); private kpiSpecialRepository = AppDataSource.getRepository(KpiSpecial); private kpiPlanHistoryRepository = AppDataSource.getRepository(KpiPlanHistory); private kpiPeriodRepository = AppDataSource.getRepository(KpiPeriod); @@ -866,9 +868,12 @@ export class kpiPlanController extends Controller { } else if (kpiPlan.child4Id != null) { type = 4; } - await this.kpiPlanHistoryRepository.delete({ kpiPlanId: id }); - await this.kpiPlanRepository.remove(kpiPlan, { data: request }); + const _null:any = null; + await this.kpiPlanHistoryRepository.delete({ kpiPlanId: id }); + await this.kpiUserPlanRepository.update({ kpiPlanId: id },{ kpiPlanId: _null }); + await this.kpiPlanRepository.remove(kpiPlan, { data: request }); + if (kpiPlan) { let remainingKpiPlans: any; if (type == 0) { diff --git a/src/controllers/KpiUserEvaluationController.ts b/src/controllers/KpiUserEvaluationController.ts index 27b4a49..e1cd0bf 100644 --- a/src/controllers/KpiUserEvaluationController.ts +++ b/src/controllers/KpiUserEvaluationController.ts @@ -171,7 +171,7 @@ export class KpiUserEvaluationController extends Controller { }); }), ) - .orderBy("kpiUserEvaluation.createdAt", "ASC") + .orderBy("kpiUserEvaluation.createdAt", "DESC") .skip((requestBody.page - 1) * requestBody.pageSize) .take(requestBody.pageSize) .getManyAndCount(); @@ -1050,7 +1050,7 @@ export class KpiUserEvaluationController extends Controller { evaluationStatus: status == undefined ? "" : status.trim().toUpperCase(), }, ) - .orderBy("kpiUserEvaluation.createdAt", "ASC") + .orderBy("kpiUserEvaluation.createdAt", "DESC") .skip((page - 1) * pageSize) .take(pageSize) .getManyAndCount();