Update code in endpoints/pen.delete.py
This commit is contained in:
parent
07c46b7a3b
commit
1e66a080e5
20
endpoints/pen.delete.py
Normal file
20
endpoints/pen.delete.py
Normal file
@ -0,0 +1,20 @@
|
||||
# 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=200, response_model=BookSchema)
|
||||
async def delete_book(
|
||||
book_id: int,
|
||||
db: Session = Depends(get_db)
|
||||
):
|
||||
book = delete_book_by_id(db, book_id)
|
||||
if not book:
|
||||
raise HTTPException(status_code=status.HTTP_404_NOT_FOUND, detail="Book not found")
|
||||
return book
|
Loading…
x
Reference in New Issue
Block a user