diff --git a/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java b/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java index f7253d95..8a8863f0 100644 --- a/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java +++ b/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java @@ -20,4 +20,7 @@ public interface BuildingRepository extends JpaRepository { "ORDER BY b.createdAt DESC") Page findFilteredBuildings(@Param("address") String address, Pageable pageable); + + @Query("SELECT b FROM Building b WHERE b.status = com.swp.PodBookingSystem.enums.BuildingStatus.Active") + List findAll(); } diff --git a/src/main/java/com/swp/PodBookingSystem/repository/RoomTypeRepository.java b/src/main/java/com/swp/PodBookingSystem/repository/RoomTypeRepository.java index cbd43809..3a064bdb 100644 --- a/src/main/java/com/swp/PodBookingSystem/repository/RoomTypeRepository.java +++ b/src/main/java/com/swp/PodBookingSystem/repository/RoomTypeRepository.java @@ -16,6 +16,7 @@ public interface RoomTypeRepository extends JpaRepository { "LEFT JOIN Room r ON r.roomType.id = rt.id " + "LEFT JOIN OrderDetail od ON r.id = od.room.id " + "WHERE (:address IS NULL OR b.address LIKE %:address%) " + + "AND b.status = com.swp.PodBookingSystem.enums.BuildingStatus.Active " + "AND (:capacity IS NULL OR rt.capacity = :capacity) " + "AND ((:startTime IS NULL AND :endTime IS NULL) " + " OR NOT EXISTS (SELECT 1 FROM OrderDetail od2 " +