deleteCateogry wift 404 bei falscher categoryID
This commit is contained in:
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()));
|
||||
|
||||
Reference in new issue
Block a user