| | |
| | | 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 |
| | |
| | | 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): |
| | |
| | | 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 |
| | | |
| | | |
| | |
| | | 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) |