feat(mixin): add TableBaseMixin and UUIDTableBaseMixin for async CRUD operations
- Implemented TableBaseMixin providing generic CRUD methods and automatic timestamp management. - Introduced UUIDTableBaseMixin for models using UUID as primary keys. - Added ListResponse for standardized paginated responses. - Created TimeFilterRequest and PaginationRequest for filtering and pagination parameters. - Enhanced get_with_count method to return both item list and total count. - Included validation for time filter parameters in TimeFilterRequest. - Improved documentation and usage examples throughout the code.
This commit is contained in:
@@ -1,15 +1,26 @@
|
||||
|
||||
from enum import StrEnum
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
from sqlmodel import Field, Relationship
|
||||
from .base import TableBase
|
||||
|
||||
from .base import SQLModelBase
|
||||
from .mixin import TableBaseMixin
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from .share import Share
|
||||
|
||||
class Report(TableBase, table=True):
|
||||
|
||||
class ReportReason(StrEnum):
|
||||
"""举报原因枚举"""
|
||||
# [TODO] 补充具体举报原因
|
||||
pass
|
||||
|
||||
|
||||
class Report(SQLModelBase, TableBaseMixin):
|
||||
"""举报模型"""
|
||||
|
||||
reason: int = Field(description="举报原因代码")
|
||||
reason: int = Field(default=0, sa_column_kwargs={"server_default": "0"})
|
||||
"""举报原因 [TODO] 待定义枚举"""
|
||||
description: str | None = Field(default=None, max_length=255, description="补充描述")
|
||||
|
||||
# 外键
|
||||
|
||||
Reference in New Issue
Block a user