deleteCateogry wift 404 bei falscher categoryID

This commit is contained in:
Technoir committed 2026-10-11 13:37:26 +02:00
1 parent 8a6bef92f7
commit 16dfd340ec
1 file changed
+2
@@ -63,6 +63,8 @@ public class ShoppingCategoryController {
throw new BadRequestException("Missing required parameter deleteAllItems (can be either true or false)");
}
shoppingCategoryRepository.findById(categoryID).orElseThrow(() -> new ResourceNotFoundException("categoryID", categoryID));
List<ShoppingItem> itemList = shoppingItemRepository.findAllByCategory_Id(categoryID);
if(deleteAllItems){
itemList.forEach((item) -> shoppingItemRepository.deleteById(item.getId()));