Update code in endpoints/kella.delete.py

This commit is contained in:
Backend IM Bot 2025-03-27 20:37:14 +01:00
parent 928256de3c
commit 54aacb3aaf

19
endpoints/kella.delete.py Normal file
View File

@ -0,0 +1,19 @@
# Entity: Book
from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from core.database import get_db
from models.book import Book
from schemas.book import BookSchema
from helpers.book_helpers import delete_book_by_id
router = APIRouter()
@router.delete("/books/{book_id}", status_code=status.HTTP_204_NO_CONTENT)
async def delete_book(
book_id: int,
db: Session = Depends(get_db)
):
if not delete_book_by_id(db, book_id):
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Book not found")
return