feat: 部门管理添加按钮级权限控制,移除部门角色表
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
from typing import Union
|
||||
|
||||
from tortoise.expressions import Q
|
||||
from fastapi import Request
|
||||
|
||||
from models import User, UserRole, RolePermission, Department
|
||||
from utils.common import filterKeyValues
|
||||
|
||||
@@ -95,7 +95,7 @@ class QueryController:
|
||||
return await User.get_or_none(Q(username=username) | Q(email=email) | Q(phone=phone), del_flag=1)
|
||||
|
||||
@classmethod
|
||||
async def get_user_permissions(cls, user_id: str,sub_departments: list = []) -> Union[list, None]:
|
||||
async def get_user_permissions(cls, user_id: str, sub_departments: list = []) -> Union[list, None]:
|
||||
"""
|
||||
获取用户权限
|
||||
"""
|
||||
@@ -141,11 +141,12 @@ class QueryController:
|
||||
async def get_sub_department_ids(cls, department_id: str) -> list:
|
||||
# 递归获取指定部门及其所有下属部门的 ID
|
||||
async def fetch_sub_deps(dep_id: str):
|
||||
sub_deps = await Department.filter(parent_id=dep_id).all()
|
||||
sub_deps = await Department.filter(parent_id=dep_id, del_flag=1).all()
|
||||
sub_deps_list = [dep.id for dep in sub_deps]
|
||||
for sub_dep in sub_deps:
|
||||
sub_deps_list.extend(await fetch_sub_deps(sub_dep.id)) # 递归获取下属部门
|
||||
return sub_deps_list
|
||||
|
||||
dataList = await fetch_sub_deps(department_id)
|
||||
dataList.append(department_id)
|
||||
return list(set(dataList))
|
||||
|
||||
Reference in New Issue
Block a user