release: Elysia ToDo v1.0.0
鍏ㄦ爤涓汉淇℃伅绠$悊搴旂敤锛岄泦鎴愬緟鍔炰换鍔°€佷範鎯墦鍗°€佺邯蹇垫棩鎻愰啋銆佽祫浜ф€昏鍔熻兘銆 Made-with: Cursor
This commit is contained in:
39
api/app/schemas/common.py
Normal file
39
api/app/schemas/common.py
Normal file
@@ -0,0 +1,39 @@
|
||||
"""
|
||||
通用响应模型
|
||||
"""
|
||||
from typing import Generic, TypeVar, List, Optional
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
T = TypeVar("T")
|
||||
|
||||
|
||||
class DeleteResponse(BaseModel):
|
||||
"""删除成功响应"""
|
||||
success: bool = Field(default=True, description="操作是否成功")
|
||||
message: str = Field(description="响应消息")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"success": True,
|
||||
"message": "删除成功"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class PaginatedResponse(BaseModel, Generic[T]):
|
||||
"""分页列表响应"""
|
||||
items: List[T] = Field(description="数据列表")
|
||||
total: int = Field(description="总记录数")
|
||||
skip: int = Field(description="跳过的记录数")
|
||||
limit: int = Field(description="返回的记录数")
|
||||
|
||||
class Config:
|
||||
json_schema_extra = {
|
||||
"example": {
|
||||
"items": [],
|
||||
"total": 0,
|
||||
"skip": 0,
|
||||
"limit": 20
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user