Update code in endpoints/store.get.py

This commit is contained in:
Backend IM Bot 2025-03-28 18:06:12 +00:00
parent 50306fae53
commit d8c1e87cd5

View File

@ -1,28 +1,13 @@
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
from models.country import Country
from schemas.country import CountrySchema
from helpers.country_helpers import get_asian_countries
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
}
@router.get("/store", response_model=List[CountrySchema], status_code=200)
async def get_asian_countries_list():
"""Get list of countries in Asia"""
countries = get_asian_countries()
return countries