feat: Update endpoint books

This commit is contained in:
Backend IM Bot 2025-03-28 11:49:02 +00:00
parent ad81bf0fee
commit c71c91de07

View File

@ -1,17 +1,15 @@
# Entity: Book from fastapi import APIRouter, Depends, HTTPException, status
from sqlalchemy.orm import Session
from fastapi import APIRouter, Depends, HTTPException, status from core.database import get_db
from sqlalchemy.orm import Session from models.book import Book
from core.database import get_db from schemas.book import BookSchema, BookCreate
from models.book import Book from helpers.book_helpers import create_book
from schemas.book import BookSchema, BookCreate
from helpers.book_helpers import create_book router = APIRouter()
router = APIRouter() @router.post("/books", status_code=201, response_model=BookSchema)
async def add_book(
@router.post("/books", status_code=201, response_model=BookSchema) book: BookCreate,
async def add_book( db: Session = Depends(get_db)
book: BookCreate, ):
db: Session = Depends(get_db)
):
return create_book(db=db, book=book) return create_book(db=db, book=book)