Ignore:
Timestamp:
03/03/24 10:52:49 (15 months ago)
Author:
Aleksandar Panovski <apano77@…>
Branches:
main
Children:
c63036a
Parents:
75f5086
Message:

RetaurantServiceImpl problemi
isAvailable od tableEntity...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/example/rezevirajmasa/demo/web/rest/testController.java

    r75f5086 rcfc16a3  
    1717import java.util.List;
    1818import java.util.Map;
     19import java.util.Optional;
    1920
    2021@CrossOrigin(origins = "http://localhost:3000/")
     
    5253    @PostMapping("/api/search")
    5354    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"));
    5758
    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);
    5961
    6062        LocalDateTime parsedDateTime = null;
     
    6769
    6870        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);
    6988    }
    7089
Note: See TracChangeset for help on using the changeset viewer.