AbstractPage -> update the create for new version
This commit is contained in:
@@ -3,7 +3,7 @@ import math
|
||||
from fastapi import Query
|
||||
from fastapi_pagination.bases import AbstractPage,AbstractParams,RawParams
|
||||
from pydantic import BaseModel
|
||||
from typing import Generic, List,TypeVar,Generic,Sequence
|
||||
from typing import Any, Generic, List, Type,TypeVar,Generic,Sequence
|
||||
from fastapi_pagination import Page,utils
|
||||
|
||||
T = TypeVar('T')
|
||||
@@ -42,7 +42,8 @@ class ApiReturnPage(AbstractPage[T],Generic[T]):
|
||||
__params_type__ =Params
|
||||
|
||||
@classmethod
|
||||
def create(cls,items:Sequence[T],total:int,params:Params) -> Page[T]:
|
||||
def create(cls,items:Sequence[T],params:Params,**kwargs: Any) -> Type[Page[T]]:
|
||||
total = kwargs.get('total', 0)
|
||||
total_pages = math.ceil(total/params.size)
|
||||
|
||||
return utils.create_pydantic_model(cls,data=items,total=total,page=params.page,size=params.size,total_pages=total_pages)
|
||||
|
||||
Reference in New Issue
Block a user