Introduce methods to count user, public, and upcoming events to enhance CRUD functionality for events. Additionally, add a `PaginatedResponse` schema to simplify and standardize paginated API responses. These updates support improved data querying and response handling.
22 lines
515 B
Python
22 lines
515 B
Python
from typing import Generic, List, TypeVar
|
|
from pydantic import BaseModel
|
|
|
|
T = TypeVar('T')
|
|
|
|
class PaginatedResponse(BaseModel, Generic[T]):
|
|
"""
|
|
Generic schema for paginated responses.
|
|
|
|
Attributes:
|
|
total (int): Total number of items
|
|
items (List[T]): List of items in the current page
|
|
page (int): Current page number
|
|
size (int): Number of items per page
|
|
"""
|
|
total: int
|
|
items: List[T]
|
|
page: int
|
|
size: int
|
|
|
|
class Config:
|
|
from_attributes = True |