28 lines
902 B
Python
28 lines
902 B
Python
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
|
|
} |