From bbd1dc3c5939df5caa01095473aae5bfec3a4da2 Mon Sep 17 00:00:00 2001 From: iSecloud <869820505@qq.com> Date: Fri, 12 Apr 2024 20:46:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E4=BF=AE=E5=A4=8Dcc=E8=BF=87?= =?UTF-8?q?=E6=BB=A4=E7=BC=93=E6=85=A2=E7=9A=84=E9=97=AE=E9=A2=98=20#3967?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ipchooser/handlers/host_handler.py | 23 ++++++++++--------- dbm-ui/backend/ticket/models/ticket.py | 2 +- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py b/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py index ad2c542650..6b968ad43d 100644 --- a/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py +++ b/dbm-ui/backend/db_services/ipchooser/handlers/host_handler.py @@ -111,8 +111,8 @@ def check( ip = ip_or_cloud_ip.split(constants.CommonEnum.SEP.value)[block_num - 1] cloud_inner_ip_set.add(f"{host_filter_cloud_id}{constants.CommonEnum.SEP.value}{ip}") + # 尝试将关键字解析为主机 ID,否则就认为是主机名 for key in key_list: - # 尝试将关键字解析为主机 ID,否则就认为是主机名 try: bk_host_id_set.add(int(key)) except ValueError: @@ -133,16 +133,17 @@ def check( ) # 构建主机过滤器 - host_property_filter = { - "condition": "OR", - "rules": [ - {"field": "bk_host_id", "operator": "in", "value": list(bk_host_id_set)}, - {"field": "bk_host_innerip", "operator": "in", "value": list(inner_ip_set)}, - {"field": "bk_host_innerip_v6", "operator": "in", "value": ipv6_list}, - {"field": "bk_host_name", "operator": "in", "value": list(bk_host_name_set)}, - ] - + cloud_ip_rules, - } + host_filter_rules: typing.List[typing.Dict] = [] + if bk_host_name_set: + host_filter_rules.append({"field": "bk_host_name", "operator": "in", "value": list(bk_host_name_set)}) + if bk_host_id_set: + host_filter_rules.append({"field": "bk_host_id", "operator": "in", "value": list(bk_host_id_set)}) + if inner_ip_set: + host_filter_rules.append({"field": "bk_host_innerip", "operator": "in", "value": list(inner_ip_set)}) + if ipv6_list: + host_filter_rules.append({"field": "bk_host_innerip_v6", "operator": "in", "value": ipv6_list}) + + host_property_filter = {"condition": "OR", "rules": host_filter_rules + cloud_ip_rules} return cls.details_base(scope_list, host_property_filter, mode) @classmethod diff --git a/dbm-ui/backend/ticket/models/ticket.py b/dbm-ui/backend/ticket/models/ticket.py index 08c92b80d3..eda0c3771d 100644 --- a/dbm-ui/backend/ticket/models/ticket.py +++ b/dbm-ui/backend/ticket/models/ticket.py @@ -116,7 +116,7 @@ class Meta: @property def url(self): - return f"{env.BK_SAAS_HOST}/{self.bk_biz_id}/my-tickets?id={self.id}" + return f"{env.BK_SAAS_HOST}/{self.bk_biz_id}/ticket-manage/index?id={self.id}" def set_terminated(self): self.status = TicketStatus.TERMINATED