39 lines
1.0 KiB
Python
39 lines
1.0 KiB
Python
from pydantic import BaseModel
|
|
from typing import Optional, TypeVar, Generic, List
|
|
from datetime import datetime
|
|
from uuid import UUID
|
|
|
|
T = TypeVar('T')
|
|
|
|
class BaseResponse(BaseModel):
|
|
"""Base response model that all other response models inherit from"""
|
|
uu_id: str
|
|
created_at: datetime
|
|
updated_at: Optional[datetime]
|
|
created_by: Optional[str]
|
|
updated_by: Optional[str]
|
|
confirmed_by: Optional[str]
|
|
is_confirmed: Optional[bool] = None
|
|
active: Optional[bool] = True
|
|
deleted: Optional[bool] = False
|
|
expiry_starts: Optional[datetime]
|
|
expiry_ends: Optional[datetime]
|
|
is_notification_send: Optional[bool] = False
|
|
is_email_send: Optional[bool] = False
|
|
|
|
class Config:
|
|
from_attributes = True
|
|
|
|
|
|
class CrudCollection(BaseModel, Generic[T]):
|
|
"""Base collection model for paginated responses"""
|
|
page: int = 1
|
|
size: int = 10
|
|
total: int = 0
|
|
order_field: str = "id"
|
|
order_type: str = "asc"
|
|
items: List[T] = []
|
|
|
|
class Config:
|
|
from_attributes = True
|