- Timestamp:
- 03/03/24 10:52:49 (15 months ago)
- Branches:
- main
- Children:
- c63036a
- Parents:
- 75f5086
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java
r75f5086 rcfc16a3 17 17 import java.util.List; 18 18 import java.util.Map; 19 import java.util.Optional; 19 20 20 21 @CrossOrigin(origins = "http://localhost:3000/") … … 52 53 @PostMapping("/api/search") 53 54 public ResponseEntity<List<Restaurant>> searchRestaurants(@RequestBody Map<String, Object> requestData) { 54 String dateTime = (String) requestData.get("dateTime");55 Integer partySize = (Integer) requestData.get("partySize");56 String search = (String) requestData.get("search");55 Optional<String> dateTimeOptional = Optional.ofNullable((String) requestData.get("dateTime")); 56 int partySize = Integer.parseInt(requestData.get("partySize").toString()); 57 Optional<String> searchOptional = Optional.ofNullable((String) requestData.get("search")); 57 58 58 // Now proceed with parsing dateTime and performing the search based on the received parameters 59 String dateTime = dateTimeOptional.orElse(null); 60 String search = searchOptional.orElse(null); 59 61 60 62 LocalDateTime parsedDateTime = null; … … 67 69 68 70 return new ResponseEntity<List<Restaurant>>(filteredRestaurants, HttpStatus.OK); 71 } 72 73 @PostMapping("/api/search/shortcut/{param}") 74 public ResponseEntity<List<Restaurant>> searchByCuisineTypeShortcut(@PathVariable String param) { 75 List<Restaurant> filteredRestaurants; 76 if(param != null && !param.isEmpty()) { 77 filteredRestaurants = restaurantService.findRestaurantsByCuisineType(param); 78 } else { 79 filteredRestaurants = restaurantService.listall(); 80 } 81 return new ResponseEntity<List<Restaurant>>(filteredRestaurants, HttpStatus.OK); 82 } 83 84 @GetMapping("/api/cuisineTypes") 85 public ResponseEntity<List<String>> getAllCuisineTypes() { 86 List<String> cuisineTypes = restaurantService.findALlCuisineTypes(); 87 return new ResponseEntity<>(cuisineTypes, HttpStatus.OK); 69 88 } 70 89
Note:
See TracChangeset
for help on using the changeset viewer.