DB 列表/仪表盘 scoped 聚合,操作日志按 user_id 过滤,工作流实例详情与审批前校验 scope。 Co-authored-by: Cursor <cursoragent@cursor.com>
28 lines
796 B
Python
28 lines
796 B
Python
"""DB 地磅模块数据权限辅助(create_by / create_dept_id)。"""
|
|
from __future__ import annotations
|
|
|
|
from typing import TYPE_CHECKING
|
|
|
|
from sqlalchemy.orm import Session
|
|
|
|
from app.core.data_scope import apply_data_scope, assert_row_in_data_scope
|
|
|
|
if TYPE_CHECKING:
|
|
from app.core.db_auth import DbUserContext
|
|
|
|
|
|
def apply_db_scope(query, model, user: "DbUserContext", db: Session, tenant_no: str):
|
|
"""列表/统计查询应用数据权限。"""
|
|
return apply_data_scope(query, model, user.to_user_info(), db, tenant_no)
|
|
|
|
|
|
def assert_db_row_in_scope(
|
|
db: Session,
|
|
row,
|
|
model,
|
|
user: "DbUserContext",
|
|
tenant_no: str,
|
|
) -> None:
|
|
"""详情/改/删前校验行级数据权限。"""
|
|
assert_row_in_data_scope(db, row, model, user.to_user_info(), tenant_no)
|