xuyonghao
2024-12-27 fdbd37eb2516b67ca41b0b71b738e3368e2825fe
用户所属部门与角色所属部门过滤
3个文件已修改
7 ■■■■■ 已修改文件
app/service/role.py 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/service/user.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/task/fetch_agent.py 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
app/service/role.py
@@ -1,6 +1,7 @@
import uuid
from Log import logger
from app.config.const import DEPT_STATUS_ON
from app.models import OrganizationModel
from app.models.resource_model import ResourceModel
from app.models.role_model import RoleModel
@@ -16,7 +17,7 @@
    total = query.count()
    roles = query.order_by(RoleModel.created_at.desc()).limit(page_size).offset(
        (page_index - 1) * page_size).all()
    return {"total": total, "rows":  [role.to_json() for role in roles]}
    return {"total": total, "rows":  [role.to_json() for role in roles if role.status == DEPT_STATUS_ON]}
async def create_role(db, role_name: str, description: str, role_key, data_scope, user_id):
app/service/user.py
@@ -385,7 +385,7 @@
async def get_user_dept(db, user_id):
    res = {}
    user = db.query(UserModel).filter_by(id=user_id).first()
    res["rows"] = [i.to_dict() for i in user.organizations]
    res["rows"] = [i.to_dict() for i in user.organizations if i.status == DEPT_STATUS_ON]
    return res
app/task/fetch_agent.py
@@ -483,7 +483,7 @@
                import_type_table(db, node)
            print("add resourceType record successfully")
        else:
            print("sync resources successfully")
            print("sync resourcesType successfully")
        if db.query(ResourceModel).count() == 0:
            with open(os.path.join(ENV_CONF_PATH, "resource.json"), 'r', encoding='utf-8') as file:
                json_data = json.load(file)