prepare fastapi root layout for server deployment
This commit is contained in:
@@ -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)
|
||||
Reference in New Issue
Block a user