From a0c6d97ea85da46212a6e1e335ce5440bf109ffd Mon Sep 17 00:00:00 2001 From: avicenan Date: Thu, 23 Apr 2026 14:30:48 +0700 Subject: [PATCH] fix service examination --- src/controllers/room_services.ts | 6 +++--- src/controllers/service_examination.ts | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/controllers/room_services.ts b/src/controllers/room_services.ts index b4f4246..f0fc4e5 100644 --- a/src/controllers/room_services.ts +++ b/src/controllers/room_services.ts @@ -154,15 +154,15 @@ export class RoomServicesController { "serviceType.name", "serviceFare.id", "serviceFare.fare", - "faretype.id", - "faretype.name", + "fareType.id", + "fareType.name", ]) .leftJoin("Service.serviceType", "serviceType") .leftJoin("Service.rooms", "room") .leftJoin("room.serviceclass", "roomClass") .innerJoin("Service.servicefare", "serviceFare") .innerJoin("serviceFare.serviceClass", "serviceClass", "serviceClass.id = roomClass.id") - .innerJoin("serviceFare.faretype", "faretype") + .innerJoin("serviceFare.faretype", "fareType") .where("room.id = :roomId", { roomId }) .orderBy("Service." + param.order_field, param.order_direction) .skip(offset) diff --git a/src/controllers/service_examination.ts b/src/controllers/service_examination.ts index 7cad55d..1ea9065 100644 --- a/src/controllers/service_examination.ts +++ b/src/controllers/service_examination.ts @@ -41,20 +41,20 @@ export class ServiceExaminationController { let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {}; - // Clone terpisah untuk count dan list - const res_count = await ServiceModel.list(filter); - const res_list = await ServiceModel.list(filter); - const offset = (param.page - 1) * param.limit; + let limit = param.limit; - res_list + var query = await ServiceModel.list(filter); + + const res_count = query; + const res_list = query .leftJoinAndSelect("Service.serviceType", "serviceType") .leftJoinAndSelect("Service.examination_details", "examinationDetails") .leftJoinAndSelect("examinationDetails.measurement_unit", "measurementUnit") .leftJoinAndSelect("examinationDetails.reference_range", "referenceRange") - .orderBy("Service." + param.order_field, param.order_direction as "ASC" | "DESC") - .offset(offset) - .limit(param.limit); + .orderBy("Service." + param.order_field, param.order_direction) + .skip(offset) + .take(limit); if (param.with_deleted) { res_count.withDeleted();