Initial monorepo structure

This commit is contained in:
Арсентьев Александр
2026-08-06 11:23:37 +03:00
commit 07dbde2a0e
240 changed files with 212717 additions and 0 deletions
+59
View File
@@ -0,0 +1,59 @@
"""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
)