Update code in endpoints/store.get.py
This commit is contained in:
parent
8b7f828fef
commit
50306fae53
28
endpoints/store.get.py
Normal file
28
endpoints/store.get.py
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from typing import List
|
||||||
|
from core.database import get_db
|
||||||
|
from models.book import Book
|
||||||
|
from models.category import Category
|
||||||
|
from models.author import Author
|
||||||
|
from schemas.book import BookSchema, BookResponse
|
||||||
|
from schemas.category import CategorySchema
|
||||||
|
from schemas.author import AuthorSchema
|
||||||
|
from helpers.store_helpers import get_store_inventory, get_categories, get_authors
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.get("/store", status_code=200, response_model=BookResponse)
|
||||||
|
async def get_store_details(
|
||||||
|
db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
"""Get store inventory with books, categories and authors"""
|
||||||
|
books = get_store_inventory(db)
|
||||||
|
categories = get_categories(db)
|
||||||
|
authors = get_authors(db)
|
||||||
|
|
||||||
|
return {
|
||||||
|
"books": books,
|
||||||
|
"categories": categories,
|
||||||
|
"authors": authors
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user