Skip to content

Commit

Permalink
fix(backend): 统一城市字段 #8805
Browse files Browse the repository at this point in the history
  • Loading branch information
iSecloud committed Dec 24, 2024
1 parent ce00665 commit da9f689
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
4 changes: 3 additions & 1 deletion dbm-ui/backend/db_services/dbbase/resources/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,8 @@ def _list_clusters(
"cluster_type": Q(cluster_type__in=query_params.get("cluster_type", "").split(",")),
# 版本
"major_version": Q(major_version__in=query_params.get("major_version", "").split(",")),
# 地域
# 地域 TODO: 城市统一为city字段,后续删除region字段
"city": Q(region__in=query_params.get("city", "").split(",")),
"region": Q(region__in=query_params.get("region", "").split(",")),
# 集群id列表
"cluster_ids": Q(id__in=query_params.get("cluster_ids")),
Expand Down Expand Up @@ -581,6 +582,7 @@ def _to_cluster_representation(
"bk_cloud_name": bk_cloud_name,
"major_version": cluster.major_version,
"region": cluster.region,
"city": cluster.region,
"db_module_name": db_module_names_map.get(cluster.db_module_id, ""),
"db_module_id": cluster.db_module_id,
"creator": cluster.creator,
Expand Down
1 change: 1 addition & 0 deletions dbm-ui/backend/db_services/dbbase/resources/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ListResourceSLZ(serializers.Serializer):
creator = serializers.CharField(required=False)
major_version = serializers.CharField(required=False)
region = serializers.CharField(required=False)
city = serializers.CharField(required=False)
cluster_ids = serializers.ListField(child=serializers.IntegerField(), required=False, allow_empty=True)
exact_domain = serializers.CharField(help_text=_("精确域名查询"), required=False)
status = serializers.CharField(required=False, help_text=_("状态"))
Expand Down
6 changes: 4 additions & 2 deletions dbm-ui/backend/db_services/ipchooser/handlers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,10 @@ def format_hosts(cls, hosts: typing.List[types.HostInfo], bk_biz_id: int = 0) ->
"bk_mem": host.get("bk_mem"),
"bk_disk": host.get("bk_disk"),
"bk_cpu": host.get("bk_cpu"),
"bk_idc_name": host.get("idc_city_name"),
"bk_idc_id": host.get("idc_city_id"),
"bk_idc_name": host.get("idc_name"),
"bk_idc_id": host.get("idc_id"),
"bk_idc_city_name": host.get("idc_city_name"),
"bk_idc_city_id": host.get("idc_city_id"),
"bk_cpu_architecture": host.get("bk_cpu_architecture"),
"bk_cpu_module": host.get("bk_cpu_module"),
}
Expand Down
6 changes: 3 additions & 3 deletions dbm-ui/backend/ticket/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,20 +137,20 @@ def _get_base_info(host):
{
**_get_base_info(host_infos[0]),
"bk_city_code": host_infos[0].get("bk_idc_id") or default_agent_city_id,
"bk_city_name": host_infos[0].get("bk_idc_name", ""),
"bk_city_name": host_infos[0].get("bk_idc_city_name", ""),
}
]
# 构造gm的部署信息
gm_host_infos = [
{
**_get_base_info(host_infos[0]),
"bk_city_code": host_infos[0].get("bk_idc_id") or default_gm_city_ids[0],
"bk_city_name": host_infos[0].get("bk_idc_name", ""),
"bk_city_name": host_infos[0].get("bk_idc_city_name", ""),
},
{
**_get_base_info(host_infos[1]),
"bk_city_code": host_infos[1].get("bk_idc_id") or default_gm_city_ids[1],
"bk_city_name": host_infos[1].get("bk_idc_name", ""),
"bk_city_name": host_infos[1].get("bk_idc_city_name", ""),
},
]

Expand Down

0 comments on commit da9f689

Please sign in to comment.