edit- und deleteList geben 404 zurück bei falscher ID

This commit is contained in:
Technoir committed 2026-10-11 13:21:30 +02:00
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());