Files
XingHuo/app/utils/response.py
T
zhanghongyu_0626 3995cb44d8 Implement authentication and chat functionality with JWT support
- Added `auth.py` for mock login and JWT issuance.
- Introduced `chat.py` for handling chat requests with role-based access control.
- Enhanced `main.py` to include new routers and middleware for tracing.
- Implemented input validation in `input_guard.py` to prevent SQL injection.
- Created repositories for managing agent sessions and audit logs.
- Added exception handling for authorization errors.
- Updated settings to include JWT configuration.
- Introduced tests for authentication and input validation.
2026-09-07 17:20:42 +08:00

16 lines
455 B
Python

"""统一 API 响应格式。"""
from __future__ import annotations
from typing import Any
from app.model.schemas import ApiResponse
def ok(data: Any, trace_id: str, message: str = "ok") -> ApiResponse:
return ApiResponse(code=0, message=message, data=data, trace_id=trace_id)
def fail(code: int, message: str, trace_id: str, *, data: Any = None) -> ApiResponse:
return ApiResponse(code=code, message=message, data=data, trace_id=trace_id)