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")}