From db0fda9a2bf8d269136ee89210cce7e30b062258 Mon Sep 17 00:00:00 2001 From: iSecloud <869820505@qq.com> Date: Wed, 20 Mar 2024 17:16:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E4=BF=AE=E5=A4=8D1.3=E6=9D=83?= =?UTF-8?q?=E9=99=90=E8=8E=B7=E5=8F=96=E8=B5=84=E6=BA=90=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98=20#3611?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/iam_app/dataclass/actions.py | 4 ++-- dbm-ui/backend/iam_app/dataclass/resources.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/dbm-ui/backend/iam_app/dataclass/actions.py b/dbm-ui/backend/iam_app/dataclass/actions.py index aa69e65469..fd46ae86a3 100644 --- a/dbm-ui/backend/iam_app/dataclass/actions.py +++ b/dbm-ui/backend/iam_app/dataclass/actions.py @@ -74,9 +74,9 @@ class ActionEnum: def get_action_by_id(cls, action_id: Union[(ActionMeta, str)]) -> ActionMeta: if isinstance(action_id, ActionMeta): return action_id - if action_id not in cls.__dict__: + if action_id.lower() not in _all_actions: raise ActionNotExistError(_("动作ID不存在: {}").format(action_id)) - return cls.__dict__[action_id] + return _all_actions[action_id.lower()] _all_actions = {action.id: action for action in ActionEnum.__dict__.values() if isinstance(action, ActionMeta)} diff --git a/dbm-ui/backend/iam_app/dataclass/resources.py b/dbm-ui/backend/iam_app/dataclass/resources.py index 6efd3010d5..82a91224f6 100644 --- a/dbm-ui/backend/iam_app/dataclass/resources.py +++ b/dbm-ui/backend/iam_app/dataclass/resources.py @@ -90,10 +90,10 @@ def get_resource_by_id(cls, resource_id: Union[ResourceMeta, str]): if isinstance(resource_id, ResourceMeta): return resource_id - if resource_id not in cls.__dict__: + if resource_id not in _all_resources: raise ResourceNotExistError(_("资源类型ID不存在: {}").format(resource_id)) - return cls.__dict__[resource_id] + return _all_resources[resource_id] _all_resources = {resource.id: resource for resource in ResourceEnum.__dict__.values() if hasattr(resource, "id")}