diff --git a/src/controllers/room_services.ts b/src/controllers/room_services.ts index 009de5e..5fad8eb 100644 --- a/src/controllers/room_services.ts +++ b/src/controllers/room_services.ts @@ -43,9 +43,16 @@ export class RoomServicesController { let param: Paging = await schema.validateAsync(req.query); let filter = param.filter && param.filter !== "" ? JSON.parse(param.filter) : {}; + const filterAny = filter.any && filter.any !== "" ? String(filter.any) : ""; + let filterObj = { ...filter } as any; + delete filterObj.any; // Get total count of rooms - const query = await RoomServicesModel.listByRoom(filter, param.with_deleted); + const query = await RoomServicesModel.listByRoom(filterObj, param.with_deleted); + if (filterAny !== "") { + const anyVal = filterAny.includes("%") ? filterAny : `%${filterAny}%`; + query.andWhere("(Room.code ILIKE :any OR Room.room ILIKE :any)", { any: anyVal }); + } const total_count_data = await query.getCount(); // Get all rooms with services