初始话项目框架

This commit is contained in:
zk
2026-03-13 13:51:51 +08:00
commit f26585a130
25 changed files with 845 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
+33
View File
@@ -0,0 +1,33 @@
import time
from typing import Any, Optional
from pydantic import BaseModel, Field
class StandardResponse(BaseModel):
"""统一响应格式"""
code: int = 200
msg: str = "正常响应"
data: Any = None
timestamp: str = Field(default_factory=lambda: str(int(time.time())))
uuid: Optional[str] = None
@classmethod
def success(
cls,
data: Any = None,
msg: str = "正常响应",
code: int = 200,
uuid: str | None = None,
) -> "StandardResponse":
return cls(code=code, msg=msg, data=data, uuid=uuid)
@classmethod
def fail(
cls,
msg: str = "操作失败",
code: int = 500,
data: Any = None,
uuid: str | None = None,
) -> "StandardResponse":
return cls(code=code, msg=msg, data=data, uuid=uuid)