mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-24 05:26:58 +00:00
此次提交进行了大规模的架构重构: 1. 移除所有平台租户相关模块和代码,包括租户管理、套餐、订单、发票等功能 2. 将菜单模块从platform迁移到system模块,统一系统功能入口 3. 移除租户隔离相关的模型混入、中间件和配置 4. 简化文件上传、SSE事件总线、定时任务等模块的租户逻辑 5. 重构所有业务schema和模型,移除租户相关字段和关联 6. 清理初始化脚本、模板和常量中的租户相关代码 7. 简化认证和权限控制逻辑,移除数据范围检查相关代码
33 lines
771 B
Python
33 lines
771 B
Python
from contextvars import ContextVar, Token
|
|
from dataclasses import dataclass
|
|
from typing import Any
|
|
|
|
# ── 日志注入 ──
|
|
_correlation_id: ContextVar[str] = ContextVar("correlation_id", default="")
|
|
|
|
|
|
def set_correlation_id(cid: str) -> Token:
|
|
return _correlation_id.set(cid)
|
|
|
|
|
|
def get_correlation_id() -> str:
|
|
return _correlation_id.get()
|
|
|
|
|
|
def reset_correlation_id(token: Token) -> None:
|
|
_correlation_id.reset(token)
|
|
|
|
|
|
# ── request.state.ctx ──
|
|
|
|
|
|
@dataclass
|
|
class RequestContext:
|
|
jwt_payload: Any = None
|
|
jwt_user_info: dict[str, Any] | None = None
|
|
session_id: str | None = None
|
|
user_id: int | None = None
|
|
user_username: str | None = None
|
|
session_info: dict[str, Any] | None = None
|
|
login_location: str | None = None
|