6c86f0f571
- integrated request-module into module registry - moved backend into modules/request-module - added manifest.json and module.py - implemented dynamic router mounting - implemented dynamic static mounting - removed direct dependencies from platform core - verified startup with request-module - verified startup without request-module - added implementation_report_003.md
60 lines
1.3 KiB
Python
60 lines
1.3 KiB
Python
"""Common schemas."""
|
|
|
|
from pydantic import BaseModel, Field
|
|
from typing import Optional, Any
|
|
|
|
|
|
class PaginationParams(BaseModel):
|
|
"""Pagination parameters."""
|
|
|
|
page: int = Field(1, ge=1, description="Page number")
|
|
page_size: int = Field(10, ge=1, le=100, description="Items per page")
|
|
|
|
@property
|
|
def offset(self) -> int:
|
|
"""Calculate offset for pagination."""
|
|
return (self.page - 1) * self.page_size
|
|
|
|
|
|
class MessageResponse(BaseModel):
|
|
"""Generic success message response."""
|
|
|
|
message: str
|
|
success: bool = True
|
|
|
|
|
|
class ErrorResponse(BaseModel):
|
|
"""Generic error response."""
|
|
|
|
message: str
|
|
error_code: Optional[str] = None
|
|
success: bool = False
|
|
|
|
|
|
class PaginatedResponse(BaseModel):
|
|
"""Generic paginated response."""
|
|
|
|
items: list[Any]
|
|
total: int
|
|
page: int
|
|
page_size: int
|
|
total_pages: int
|
|
|
|
@classmethod
|
|
def create(
|
|
cls,
|
|
items: list[Any],
|
|
total: int,
|
|
page: int,
|
|
page_size: int
|
|
) -> "PaginatedResponse":
|
|
"""Create paginated response."""
|
|
total_pages = (total + page_size - 1) // page_size
|
|
return cls(
|
|
items=items,
|
|
total=total,
|
|
page=page,
|
|
page_size=page_size,
|
|
total_pages=total_pages
|
|
)
|