prepare fastapi root layout for server deployment

This commit is contained in:
刘金宝
2026-06-04 10:55:23 +08:00
parent eb43573a44
commit b46e43aadc
103 changed files with 347 additions and 197 deletions
+18
View File
@@ -0,0 +1,18 @@
from typing import Generic, TypeVar
from pydantic import BaseModel
T = TypeVar("T")
class ApiResponse(BaseModel, Generic[T]):
"""统一响应:所有业务接口使用相同的 `code/message/data` 结构。"""
code: str = "OK"
message: str = "success"
data: T | None = None
def ok(data: T | None = None) -> ApiResponse[T]:
"""响应封装:生成成功响应对象。"""
return ApiResponse(data=data)