Update code in endpoints/store.get.py
This commit is contained in:
parent
50306fae53
commit
d8c1e87cd5
@ -1,28 +1,13 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
from sqlalchemy.orm import Session
|
|
||||||
from typing import List
|
from typing import List
|
||||||
from core.database import get_db
|
from models.country import Country
|
||||||
from models.book import Book
|
from schemas.country import CountrySchema
|
||||||
from models.category import Category
|
from helpers.country_helpers import get_asian_countries
|
||||||
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 = APIRouter()
|
||||||
|
|
||||||
@router.get("/store", status_code=200, response_model=BookResponse)
|
@router.get("/store", response_model=List[CountrySchema], status_code=200)
|
||||||
async def get_store_details(
|
async def get_asian_countries_list():
|
||||||
db: Session = Depends(get_db)
|
"""Get list of countries in Asia"""
|
||||||
):
|
countries = get_asian_countries()
|
||||||
"""Get store inventory with books, categories and authors"""
|
return countries
|
||||||
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