Files
guwangtu b91954df4a
CI / check (push) Failing after 15m48s
chore: initial open-source baseline v1.0.0
Signed-off-by: 南通一次元科技有限公司 <guwangtu@icimeta.com>
2026-12-05 15:44:53 +00:00

22 lines
582 B
Python

# -*- coding: utf-8 -*-
"""请求级操作人上下文。
门户中间件根据登录会话设置当前操作人,各业务服务的日志/流转记录
统一通过 get_operator() 取真实用户,避免再硬编码“审计管理员”。
"""
import contextvars
_current = contextvars.ContextVar("audit_operator", default="系统")
def set_operator(name: str) -> None:
value = (name or "系统").strip()
_current.set(value[:40] or "系统")
def get_operator() -> str:
try:
return _current.get() or "系统"
except Exception:
return "系统"