Update code in endpoints/penas.delete.py
This commit is contained in:
parent
d8465d23ee
commit
928256de3c
19
endpoints/penas.delete.py
Normal file
19
endpoints/penas.delete.py
Normal 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
|
Loading…
x
Reference in New Issue
Block a user