This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
from typing import List
|
||||
|
||||
from fastapi import APIRouter
|
||||
|
||||
from src.db.models.bookshelf import Article
|
||||
from src.db.session import SessionDep
|
||||
from src.schema.bookshelf.article import ArticleResponse, to_response
|
||||
|
||||
|
||||
router = APIRouter()
|
||||
|
||||
|
||||
@router.get("/articles", response_model=List[ArticleResponse])
|
||||
def get_all_artists(db: SessionDep) -> List[ArticleResponse]:
|
||||
results: List[ArticleResponse] = []
|
||||
articles = db.query(Article).all()
|
||||
for article in articles:
|
||||
response = to_response(article)
|
||||
results.append(response)
|
||||
return results
|
||||
Reference in New Issue
Block a user