Signed-off-by: 南通一次元科技有限公司 <guwangtu@icimeta.com>
This commit is contained in:
commit
b91954df4a
106 files changed
+43359
No files matched your search
@@ -0,0 +1,21 @@
|
||||
# -*- 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 "系统"
|
||||
Reference in new issue
Block a user