Optimize routes to better align with RESTful (#673)

* Optimize routes to better align with RESTful

* Add codes endpoint description

* Update jinja templates

* fix typo

* fix sql
This commit is contained in:
Wu Clan
2025-06-19 11:06:34 +08:00
committed by GitHub
parent 0d1f05d307
commit 319ba13df1
74 changed files with 626 additions and 642 deletions
+1 -1
View File
@@ -231,7 +231,7 @@ def superuser_verify(request: Request) -> bool:
"""
superuser = request.user.is_superuser
if not superuser or not request.user.is_staff:
raise errors.AuthorizationError
raise errors.AuthorizationError()
return superuser
+5 -8
View File
@@ -64,23 +64,20 @@ async def filter_data_permission(db: AsyncSession, request: Request) -> ColumnEl
return or_(1 == 1)
# 获取数据范围
unique_data_scopes = {}
data_scope_ids = set()
for role in request.user.roles:
for scope in role.scopes:
if scope.status:
unique_data_scopes[scope.id] = scope
# 转换为列表
data_scopes = list(unique_data_scopes.values())
data_scope_ids.add(scope.id)
# 无规则用户不做过滤
if not data_scopes:
if not list(data_scope_ids):
return or_(1 == 1)
# 获取数据范围规则
unique_data_rules = {}
for data_scope in data_scopes:
data_scope_with_relation = await data_scope_dao.get_with_relation(db, data_scope.id)
for data_scope_id in list(data_scope_ids):
data_scope_with_relation = await data_scope_dao.get_with_relation(db, data_scope_id)
for rule in data_scope_with_relation.rules:
unique_data_rules[rule.id] = rule