diff --git a/src/model/room_services.ts b/src/model/room_services.ts index 7557b11..bc350e3 100644 --- a/src/model/room_services.ts +++ b/src/model/room_services.ts @@ -9,7 +9,7 @@ export class RoomServicesModel { const repo = OrmHelper.DB.getRepository(Service); let whereAttr: string[] = []; let whereVal: any = {}; - + if (filter && Object.keys(filter).length > 0) { const filterResult = CommonHelper.handleQueryFilter(filter); whereAttr = [...whereAttr, ...filterResult.whereAttr]; @@ -18,7 +18,8 @@ export class RoomServicesModel { let query = repo.createQueryBuilder("Service") .leftJoinAndSelect("Service.rooms", "Room") - .leftJoinAndSelect("Room.department", "Department"); + .leftJoinAndSelect("Room.department", "Department") + .leftJoinAndSelect("Service.serviceType", "ServiceType"); if (whereAttr.length != 0) { query = query.where(whereAttr.join(" and "), whereVal); @@ -35,7 +36,7 @@ export class RoomServicesModel { const repo = OrmHelper.DB.getRepository(Room); let whereAttr: string[] = []; let whereVal: any = {}; - + if (filter && Object.keys(filter).length > 0) { const filterResult = CommonHelper.handleQueryFilter(filter, "Room"); whereAttr = [...whereAttr, ...filterResult.whereAttr]; @@ -44,7 +45,8 @@ export class RoomServicesModel { let query = repo.createQueryBuilder("Room") .leftJoinAndSelect("Room.services", "Service") - .leftJoinAndSelect("Room.department", "Department"); + .leftJoinAndSelect("Room.department", "Department") + .leftJoinAndSelect("Service.serviceType", "ServiceType"); if (whereAttr.length != 0) { query = query.where(whereAttr.join(" and "), whereVal); @@ -60,7 +62,7 @@ export class RoomServicesModel { // Method untuk count rooms (bukan relationships) static async countRooms(filter = {}, withDeleted = false): Promise { const repo = OrmHelper.DB.getRepository(Service); - + // Query untuk menghitung total unique rooms yang punya services let queryBuilder = repo.createQueryBuilder("Service") .innerJoin("Service.rooms", "Room") @@ -84,7 +86,7 @@ export class RoomServicesModel { // Method untuk count services static async countServices(filter = {}, withDeleted = false): Promise { const repo = OrmHelper.DB.getRepository(Room); - + // Query untuk menghitung total unique services yang punya rooms let queryBuilder = repo.createQueryBuilder("Room") .innerJoin("Room.services", "Service")