edit- und deleteList geben 404 zurück bei falscher ID
This commit is contained in:
1 parent
a6063ad842
commit
c8808a9f23
1 file changed
+3
-1
@@ -38,13 +38,15 @@ public class ShoppingListController {
|
||||
}
|
||||
@DeleteMapping("/api/lists/{listID}")
|
||||
public ResponseEntity<Void> deleteList(@PathVariable UUID listID){
|
||||
shoppingListRepository.findById(listID).orElseThrow(() -> new ResourceNotFoundException("listID",listID));
|
||||
|
||||
shoppingListService.deleteList(listID);
|
||||
return ResponseEntity.noContent().build();
|
||||
}
|
||||
|
||||
@PatchMapping("/api/lists/{listID}")
|
||||
public ResponseEntity<Void> editList(@PathVariable UUID listID,@RequestBody ShoppingListPatchDTO toChange){
|
||||
ShoppingList list = shoppingListRepository.findById(listID).orElseThrow();
|
||||
ShoppingList list = shoppingListRepository.findById(listID).orElseThrow(() -> new ResourceNotFoundException("listID", listID));
|
||||
|
||||
if(toChange.newListName() != null) list.setListName(toChange.newListName());
|
||||
|
||||
|
||||
Reference in new issue
Block a user