From 5dd6018143d4ea34d6627540920beab4ae570fe1 Mon Sep 17 00:00:00 2001 From: iSecloud <869820505@qq.com> Date: Thu, 19 Dec 2024 11:08:46 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E4=BF=AE=E5=A4=8D=E9=9B=86?= =?UTF-8?q?=E7=BE=A4=E8=AE=B0=E5=BD=95=E5=88=97=E8=A1=A8=E5=B1=95=E7=A4=BA?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20#8723?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/ticket/builders/__init__.py | 6 ++++++ dbm-ui/backend/ticket/builders/mysql/mysql_data_repair.py | 5 +++-- .../backend/ticket/builders/tendbcluster/tendb_dump_data.py | 3 ++- dbm-ui/backend/ticket/flow_manager/pause.py | 2 +- dbm-ui/backend/ticket/views.py | 4 ++-- 5 files changed, 14 insertions(+), 6 deletions(-) diff --git a/dbm-ui/backend/ticket/builders/__init__.py b/dbm-ui/backend/ticket/builders/__init__.py index 20b3bdd564..77828cd731 100644 --- a/dbm-ui/backend/ticket/builders/__init__.py +++ b/dbm-ui/backend/ticket/builders/__init__.py @@ -171,6 +171,11 @@ def __init__(self, ticket: Ticket): self.ticket_data = copy.deepcopy(ticket.details) self.params = {"pause_type": None} + @property + def operators(self): + """当前单据指定处理人""" + return [] + def format(self): """ 这里可以为params添加更多参数 @@ -180,6 +185,7 @@ def format(self): def get_params(self): self.format() + self.params.update(operators=self.operators) self.params = super().inject_callback_in_params(params=self.params) return self.params diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_data_repair.py b/dbm-ui/backend/ticket/builders/mysql/mysql_data_repair.py index 052ea02d42..76c73d1af3 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_data_repair.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_data_repair.py @@ -44,10 +44,11 @@ class MySQLDataRepairFlowParamBuilder(builders.FlowParamBuilder): class MySQLDataRepairPauseParamBuilder(builders.PauseParamBuilder): """MySQL 数据校验暂停参数""" - def format(self): + @property + def operators(self): # 数据修复目前都是自动发起,确认人加上业务主备DBA dba = DBAdministrator.get_biz_db_type_admins(self.ticket.bk_biz_id, self.ticket.group)[:2] - self.params.update(operators=dba) + return dba @builders.BuilderFactory.register(TicketType.MYSQL_DATA_REPAIR) diff --git a/dbm-ui/backend/ticket/builders/tendbcluster/tendb_dump_data.py b/dbm-ui/backend/ticket/builders/tendbcluster/tendb_dump_data.py index 15d05c91c0..17d718f2a9 100644 --- a/dbm-ui/backend/ticket/builders/tendbcluster/tendb_dump_data.py +++ b/dbm-ui/backend/ticket/builders/tendbcluster/tendb_dump_data.py @@ -14,6 +14,7 @@ from backend.ticket import builders from backend.ticket.builders.mysql.mysql_dump_data import ( MySQLDumpDataDetailSerializer, + MySQLDumpDataFlowBuilder, MySQLDumpDataFlowParamBuilder, MySQLDumpDataItsmFlowParamsBuilder, ) @@ -34,7 +35,7 @@ class TendbClusterDumpDataItsmFlowParamsBuilder(MySQLDumpDataItsmFlowParamsBuild @builders.BuilderFactory.register(TicketType.TENDBCLUSTER_DUMP_DATA) -class TendbClusterDumpDataFlowBuilder(BaseTendbTicketFlowBuilder): +class TendbClusterDumpDataFlowBuilder(BaseTendbTicketFlowBuilder, MySQLDumpDataFlowBuilder): serializer = TendbClusterDumpDataDetailSerializer itsm_flow_builder = TendbClusterDumpDataItsmFlowParamsBuilder inner_flow_builder = TendbClusterDumpDataFlowParamBuilder diff --git a/dbm-ui/backend/ticket/flow_manager/pause.py b/dbm-ui/backend/ticket/flow_manager/pause.py index b643e87b9f..cc0ff049ca 100644 --- a/dbm-ui/backend/ticket/flow_manager/pause.py +++ b/dbm-ui/backend/ticket/flow_manager/pause.py @@ -60,7 +60,7 @@ def _run(self) -> Union[int, str]: # 创建待办 from backend.ticket.todos.pause_todo import PauseTodoContext - operators = list({self.ticket.creator, *self.flow_obj.details.get("operators", [])}) + operators = self.flow_obj.details.get("operators", []) Todo.objects.create( name=_("【{}】流程待确认,是否继续?").format(self.ticket.get_ticket_type_display()), flow=self.flow_obj, diff --git a/dbm-ui/backend/ticket/views.py b/dbm-ui/backend/ticket/views.py index d2a11f8cae..da5564f73c 100644 --- a/dbm-ui/backend/ticket/views.py +++ b/dbm-ui/backend/ticket/views.py @@ -483,7 +483,7 @@ def get_tickets_count(self, request, *args, **kwargs): filter_class=ClusterOpRecordListFilter, ) def get_cluster_operate_records(self, request, *args, **kwargs): - op_records_page_qs = self.paginate_queryset(self.filter_queryset(self.queryset)) + op_records_page_qs = self.paginate_queryset(super().filter_queryset(self.queryset)) op_records_page_data = self.serializer_class(op_records_page_qs, many=True).data return self.get_paginated_response(data=op_records_page_data) @@ -499,7 +499,7 @@ def get_cluster_operate_records(self, request, *args, **kwargs): filter_class=InstanceOpRecordListFilter, ) def get_instance_operate_records(self, request, *args, **kwargs): - op_records_page_qs = self.paginate_queryset(self.filter_queryset(self.queryset)) + op_records_page_qs = self.paginate_queryset(super().filter_queryset(self.queryset)) op_records_page_data = self.serializer_class(op_records_page_qs, many=True).data return self.get_paginated_response(data=op_records_page_data)