dingdanquanliucheng/backend/app/core/responses.py

13 lines
366 B
Python
Raw Normal View History

2026-05-14 10:15:51 +08:00
from typing import Any
2026-05-14 13:51:06 +08:00
from backend.app.core.error_codes import ErrorCode
2026-05-14 10:15:51 +08:00
2026-05-14 13:51:06 +08:00
def success_response(data: Any = None, message: str = "success") -> dict[str, Any]:
# 成功响应统一走这里,便于后续扩展 trace_id 等字段。
return {
"code": ErrorCode.SUCCESS,
"message": message,
"data": {} if data is None else data,
}