diff --git a/src/main/java/com/swp/PodBookingSystem/controller/BuildingController.java b/src/main/java/com/swp/PodBookingSystem/controller/BuildingController.java index 1fe2c940..a1fa08ad 100644 --- a/src/main/java/com/swp/PodBookingSystem/controller/BuildingController.java +++ b/src/main/java/com/swp/PodBookingSystem/controller/BuildingController.java @@ -107,4 +107,12 @@ ApiResponse> getAllBuildings() { .message("Get all buildings successfully") .build(); } + + @GetMapping("/buildings-option") + ApiResponse> getAllBuildingsForHomePage() { + return ApiResponse.>builder() + .data(buildingService.getAllBuildingsForHomePage()) + .message("Get all buildings successfully") + .build(); + } } diff --git a/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java b/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java index 971a7b96..d02b3117 100644 --- a/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java +++ b/src/main/java/com/swp/PodBookingSystem/repository/BuildingRepository.java @@ -20,5 +20,5 @@ 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(); + List findAllBuildingForHomPage(); } diff --git a/src/main/java/com/swp/PodBookingSystem/service/BuildingService.java b/src/main/java/com/swp/PodBookingSystem/service/BuildingService.java index 9dcfd16e..15fcb4fd 100644 --- a/src/main/java/com/swp/PodBookingSystem/service/BuildingService.java +++ b/src/main/java/com/swp/PodBookingSystem/service/BuildingService.java @@ -76,4 +76,8 @@ public List searchBuildings(String keyword) { public List getAllBuildings() { return buildingRepository.findAll(); } + + public List getAllBuildingsForHomePage() { + return buildingRepository.findAllBuildingForHomPage(); + } }