Add event counting methods and generic pagination schema
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.
This commit is contained in:
22
backend/app/schemas/common.py
Normal file
22
backend/app/schemas/common.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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
|
||||
Reference in New Issue
Block a user