mirror of
https://github.com/flibusta-apps/book_library_server.git
synced 2026-03-03 15:10:51 +01:00
Fix
This commit is contained in:
@@ -8,6 +8,7 @@ from app.views.sequence import sequence_router
|
||||
from app.views.source import source_router
|
||||
from app.views.translation import translation_router
|
||||
|
||||
|
||||
routers = [
|
||||
source_router,
|
||||
author_router,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
|
||||
from fastapi_pagination import Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
@@ -10,7 +11,8 @@ from app.serializers.author import Author, AuthorBook, TranslatedBook
|
||||
from app.serializers.author_annotation import AuthorAnnotation
|
||||
from app.services.author import AuthorMeiliSearchService, GetRandomAuthorService
|
||||
from app.services.translator import TranslatorMeiliSearchService
|
||||
from app.utils.pagination import CustomPage
|
||||
from app.utils.pagination import Page
|
||||
|
||||
|
||||
author_router = APIRouter(
|
||||
prefix="/api/v1/authors",
|
||||
@@ -23,9 +25,7 @@ PREFETCH_RELATED_FIELDS = ["source"]
|
||||
SELECT_RELATED_FIELDS = ["annotations"]
|
||||
|
||||
|
||||
@author_router.get(
|
||||
"/", response_model=CustomPage[Author], dependencies=[Depends(Params)]
|
||||
)
|
||||
@author_router.get("/", response_model=Page[Author], dependencies=[Depends(Params)])
|
||||
async def get_authors():
|
||||
return await paginate(
|
||||
AuthorDB.objects.select_related(SELECT_RELATED_FIELDS).prefetch_related(
|
||||
@@ -75,7 +75,7 @@ async def get_author_annotation(id: int):
|
||||
|
||||
|
||||
@author_router.get(
|
||||
"/{id}/books", response_model=CustomPage[AuthorBook], dependencies=[Depends(Params)]
|
||||
"/{id}/books", response_model=Page[AuthorBook], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def get_author_books(
|
||||
id: int, allowed_langs: list[str] = Depends(get_allowed_langs)
|
||||
@@ -89,7 +89,7 @@ async def get_author_books(
|
||||
|
||||
|
||||
@author_router.get(
|
||||
"/search/{query}", response_model=CustomPage[Author], dependencies=[Depends(Params)]
|
||||
"/search/{query}", response_model=Page[Author], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def search_authors(
|
||||
query: str,
|
||||
@@ -109,7 +109,7 @@ translator_router = APIRouter(
|
||||
)
|
||||
|
||||
|
||||
@translator_router.get("/{id}/books", response_model=CustomPage[TranslatedBook])
|
||||
@translator_router.get("/{id}/books", response_model=Page[TranslatedBook])
|
||||
async def get_translated_books(
|
||||
id: int, allowed_langs: list[str] = Depends(get_allowed_langs)
|
||||
):
|
||||
@@ -125,7 +125,7 @@ async def get_translated_books(
|
||||
|
||||
|
||||
@translator_router.get(
|
||||
"/search/{query}", response_model=CustomPage[Author], dependencies=[Depends(Params)]
|
||||
"/search/{query}", response_model=Page[Author], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def search_translators(
|
||||
query: str,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from fastapi_pagination import Page, Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
@@ -6,6 +7,7 @@ from app.depends import check_token
|
||||
from app.models import AuthorAnnotation as AuthorAnnotationDB
|
||||
from app.serializers.author_annotation import AuthorAnnotation
|
||||
|
||||
|
||||
author_annotation_router = APIRouter(
|
||||
prefix="/api/v1/author_annotations",
|
||||
tags=["author_annotation"],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
|
||||
from fastapi_pagination import Params
|
||||
|
||||
from app.depends import check_token, get_allowed_langs
|
||||
@@ -15,7 +16,8 @@ from app.services.book import (
|
||||
BookMeiliSearchService,
|
||||
GetRandomBookService,
|
||||
)
|
||||
from app.utils.pagination import CustomPage
|
||||
from app.utils.pagination import Page
|
||||
|
||||
|
||||
book_router = APIRouter(
|
||||
prefix="/api/v1/books",
|
||||
@@ -29,9 +31,7 @@ SELECT_RELATED_FIELDS = ["authors", "translators", "annotations"]
|
||||
DETAIL_SELECT_RELATED_FIELDS = ["sequences", "genres"]
|
||||
|
||||
|
||||
@book_router.get(
|
||||
"/", response_model=CustomPage[RemoteBook], dependencies=[Depends(Params)]
|
||||
)
|
||||
@book_router.get("/", response_model=Page[RemoteBook], dependencies=[Depends(Params)])
|
||||
async def get_books(
|
||||
request: Request,
|
||||
book_filter: dict = Depends(get_book_filter),
|
||||
@@ -40,7 +40,7 @@ async def get_books(
|
||||
|
||||
|
||||
@book_router.get(
|
||||
"/base/", response_model=CustomPage[BookBaseInfo], dependencies=[Depends(Params)]
|
||||
"/base/", response_model=Page[BookBaseInfo], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def get_base_books_info(
|
||||
request: Request, book_filter: dict = Depends(get_book_filter)
|
||||
@@ -116,7 +116,7 @@ async def get_book_annotation(id: int):
|
||||
|
||||
|
||||
@book_router.get(
|
||||
"/search/{query}", response_model=CustomPage[Book], dependencies=[Depends(Params)]
|
||||
"/search/{query}", response_model=Page[Book], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def search_books(
|
||||
query: str,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, status
|
||||
|
||||
from fastapi_pagination import Page, Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
@@ -6,6 +7,7 @@ from app.depends import check_token
|
||||
from app.models import BookAnnotation as BookAnnotationDB
|
||||
from app.serializers.book_annotation import BookAnnotation
|
||||
|
||||
|
||||
book_annotation_router = APIRouter(
|
||||
prefix="/api/v1/book_annotations",
|
||||
tags=["book_annotation"],
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, HTTPException, Request, status
|
||||
|
||||
from fastapi_pagination import Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
@@ -7,7 +8,8 @@ from app.filters.genre import get_genre_filter
|
||||
from app.models import Genre as GenreDB
|
||||
from app.serializers.genre import Genre
|
||||
from app.services.genre import GenreMeiliSearchService
|
||||
from app.utils.pagination import CustomPage
|
||||
from app.utils.pagination import Page
|
||||
|
||||
|
||||
genre_router = APIRouter(
|
||||
prefix="/api/v1/genres", tags=["genres"], dependencies=[Depends(check_token)]
|
||||
@@ -17,7 +19,7 @@ genre_router = APIRouter(
|
||||
PREFETCH_RELATED_FIELDS = ["source"]
|
||||
|
||||
|
||||
@genre_router.get("/", response_model=CustomPage[Genre], dependencies=[Depends(Params)])
|
||||
@genre_router.get("/", response_model=Page[Genre], dependencies=[Depends(Params)])
|
||||
async def get_genres(genre_filter: dict = Depends(get_genre_filter)):
|
||||
return await paginate(
|
||||
GenreDB.objects.prefetch_related(PREFETCH_RELATED_FIELDS)
|
||||
@@ -46,7 +48,7 @@ async def get_genre(id: int):
|
||||
|
||||
|
||||
@genre_router.get(
|
||||
"/search/{query}", response_model=CustomPage[Genre], dependencies=[Depends(Params)]
|
||||
"/search/{query}", response_model=Page[Genre], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def search_genres(
|
||||
query: str,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
|
||||
healtcheck_router = APIRouter(tags=["healthcheck"])
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends, Request
|
||||
|
||||
from fastapi_pagination import Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
@@ -8,7 +9,8 @@ from app.models import Sequence as SequenceDB
|
||||
from app.serializers.sequence import Book as SequenceBook
|
||||
from app.serializers.sequence import Sequence
|
||||
from app.services.sequence import GetRandomSequenceService, SequenceMeiliSearchService
|
||||
from app.utils.pagination import CustomPage
|
||||
from app.utils.pagination import Page
|
||||
|
||||
|
||||
sequence_router = APIRouter(
|
||||
prefix="/api/v1/sequences",
|
||||
@@ -17,9 +19,7 @@ sequence_router = APIRouter(
|
||||
)
|
||||
|
||||
|
||||
@sequence_router.get(
|
||||
"/", response_model=CustomPage[Sequence], dependencies=[Depends(Params)]
|
||||
)
|
||||
@sequence_router.get("/", response_model=Page[Sequence], dependencies=[Depends(Params)])
|
||||
async def get_sequences():
|
||||
return await paginate(SequenceDB.objects)
|
||||
|
||||
@@ -44,7 +44,7 @@ async def get_sequence(id: int):
|
||||
|
||||
@sequence_router.get(
|
||||
"/{id}/books",
|
||||
response_model=CustomPage[SequenceBook],
|
||||
response_model=Page[SequenceBook],
|
||||
dependencies=[Depends(Params)],
|
||||
)
|
||||
async def get_sequence_books(
|
||||
@@ -60,7 +60,7 @@ async def get_sequence_books(
|
||||
|
||||
@sequence_router.get(
|
||||
"/search/{query}",
|
||||
response_model=CustomPage[Sequence],
|
||||
response_model=Page[Sequence],
|
||||
dependencies=[Depends(Params)],
|
||||
)
|
||||
async def search_sequences(
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from fastapi_pagination import Page, Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
@@ -6,6 +7,7 @@ from app.depends import check_token
|
||||
from app.models import Source as SourceDB
|
||||
from app.serializers.source import Source
|
||||
|
||||
|
||||
source_router = APIRouter(
|
||||
prefix="/api/v1/sources",
|
||||
tags=["source"],
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from fastapi_pagination import Params
|
||||
from fastapi_pagination.ext.ormar import paginate
|
||||
|
||||
from app.depends import check_token
|
||||
from app.models import Translation as TranslationDB
|
||||
from app.serializers.translation import Translation
|
||||
from app.utils.pagination import CustomPage
|
||||
from app.utils.pagination import Page
|
||||
|
||||
|
||||
translation_router = APIRouter(
|
||||
prefix="/api/v1/translation",
|
||||
@@ -15,7 +17,7 @@ translation_router = APIRouter(
|
||||
|
||||
|
||||
@translation_router.get(
|
||||
"/", response_model=CustomPage[Translation], dependencies=[Depends(Params)]
|
||||
"/", response_model=Page[Translation], dependencies=[Depends(Params)]
|
||||
)
|
||||
async def get_translations():
|
||||
return await paginate(TranslationDB.objects.select_related(["book", "author"]))
|
||||
|
||||
Reference in New Issue
Block a user