Skip to content
Snippets Groups Projects
Commit cf213fb3 authored by Anders Austlid's avatar Anders Austlid
Browse files

Changed setup of ShoppingListController endpoint URLs

parent 44eccee7
No related branches found
No related tags found
No related merge requests found
...@@ -44,7 +44,7 @@ public class ShoppingListController { ...@@ -44,7 +44,7 @@ public class ShoppingListController {
* @param id the shopping list ID * @param id the shopping list ID
* @return the shopping list, or an error if the ID is invalid * @return the shopping list, or an error if the ID is invalid
*/ */
@GetMapping("shoppinglist/{id}") @GetMapping("/{id}")
public ResponseEntity<ShoppingList> getShoppingListById(@PathVariable("id") long id) { public ResponseEntity<ShoppingList> getShoppingListById(@PathVariable("id") long id) {
Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListById(id); Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListById(id);
return shoppingList.map(list -> ResponseEntity.status(HttpStatus.OK).body(list)) return shoppingList.map(list -> ResponseEntity.status(HttpStatus.OK).body(list))
...@@ -54,12 +54,12 @@ public class ShoppingListController { ...@@ -54,12 +54,12 @@ public class ShoppingListController {
/** /**
* Gets a shopping list by its group ID * Gets a shopping list by its group ID
* *
* @param request the request containing the group ID * @param id the request containing the group ID
* @return the shopping list, or an error if the ID is invalid * @return the shopping list, or an error if the ID is invalid
*/ */
@GetMapping("/group/shoppinglist") @GetMapping("/group/{id}")
public ResponseEntity<ShoppingList> getAllShoppingListsByGroupId(@RequestBody ShoppingListRequest request) { public ResponseEntity<ShoppingList> getAllShoppingListsByGroupId(@PathVariable("id") long id) {
Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListByGroupId(request.getGroupID()); Optional<ShoppingList> shoppingList = shoppingListService.getShoppingListByGroupId(id);
return shoppingList.map(list -> ResponseEntity.status(HttpStatus.OK).body(list)) return shoppingList.map(list -> ResponseEntity.status(HttpStatus.OK).body(list))
.orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build()); .orElseGet(() -> ResponseEntity.status(HttpStatus.NOT_FOUND).build());
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment