feat(db): 地磅、操作日志与工作流补全数据权限过滤
DB 列表/仪表盘 scoped 聚合,操作日志按 user_id 过滤,工作流实例详情与审批前校验 scope。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2905dc3d5f
commit
66d5a8714b
8 files changed
+284
-92
No files matched your search
@@ -13,16 +13,28 @@ from app.schemas.monitor.operlog import OperLogDetailBody, OperLogListBody
|
||||
router = APIRouter(prefix="/web/monitor", tags=["系统监控"])
|
||||
|
||||
|
||||
def _user_info(user: dict) -> dict:
|
||||
dept_id = (user.get("region_id") or user.get("dept_id") or "").strip()
|
||||
return {
|
||||
"user_id": (user.get("user_id") or user.get("id") or "").strip(),
|
||||
"role": (user.get("role") or "").strip(),
|
||||
"tenant_no": (user.get("tenant_no") or "").strip(),
|
||||
"dept_id": dept_id,
|
||||
"region_id": dept_id,
|
||||
}
|
||||
|
||||
|
||||
@router.post("/operlog/list")
|
||||
async def operlog_list(
|
||||
body: OperLogListBody = None,
|
||||
_user: dict = Depends(require_admin_or_super_admin),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""操作日志分页列表(基于 API 请求日志适配 RuoYi OperLog 结构)"""
|
||||
try:
|
||||
page = body.page if body else 1
|
||||
page_size = body.page_size if body else 10
|
||||
info = _user_info(user)
|
||||
rows, total = list_oper_logs(
|
||||
db,
|
||||
page=page,
|
||||
@@ -31,6 +43,8 @@ async def operlog_list(
|
||||
business_type=body.business_type if body else None,
|
||||
oper_name=body.oper_name if body else None,
|
||||
status=body.status if body else None,
|
||||
user_info=info,
|
||||
tenant_no=info.get("tenant_no"),
|
||||
)
|
||||
total_pages = (total + page_size - 1) // page_size if page_size else 0
|
||||
return success_response(
|
||||
@@ -50,12 +64,13 @@ async def operlog_list(
|
||||
@router.post("/operlog/detail")
|
||||
async def operlog_detail(
|
||||
body: OperLogDetailBody,
|
||||
_user: dict = Depends(require_admin_or_super_admin),
|
||||
user: dict = Depends(require_admin_or_super_admin),
|
||||
db: Session = Depends(get_db),
|
||||
):
|
||||
"""操作日志详情"""
|
||||
try:
|
||||
row = get_oper_log(db, body.id)
|
||||
info = _user_info(user)
|
||||
row = get_oper_log(db, body.id, user_info=info, tenant_no=info.get("tenant_no"))
|
||||
if not row:
|
||||
return error_response(404, "操作日志不存在")
|
||||
return success_response(row)
|
||||
|
||||
Reference in new issue
Block a user