From eeb744fab0184731e1837e981cbb7c7f1b879248 Mon Sep 17 00:00:00 2001 From: ycggyao Date: Mon, 25 Nov 2024 17:25:52 +0800 Subject: [PATCH] =?UTF-8?q?feat(backend):=20=E5=8D=95=E6=8D=AE=E5=8D=8F?= =?UTF-8?q?=E5=8A=A9=E8=AE=BE=E7=BD=AE=E5=BC=80=E5=8F=91=20#8036=20#=20Rev?= =?UTF-8?q?iewed,=20transaction=20id:=2024730?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/configuration/constants.py | 2 ++ dbm-ui/backend/ticket/models/todo.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/dbm-ui/backend/configuration/constants.py b/dbm-ui/backend/configuration/constants.py index 30c5bedcf2..643dcb805d 100644 --- a/dbm-ui/backend/configuration/constants.py +++ b/dbm-ui/backend/configuration/constants.py @@ -127,6 +127,8 @@ class BizSettingsEnum(str, StructuredEnum): # TODO: 后续待删除 SKIP_GRAMMAR_CHECK = EnumField("SKIP_GRAMMAR_CHECK", _("是否跳过语义检查")) SQL_IMPORT_FORCE_ITSM = EnumField("SQL_IMPORT_FORCE_ITSM", _("是否变更SQL强制需要审批流")) + BIZ_ASSISTANCE_VARS = EnumField("BIZ_ASSISTANCE_VARS", _("业务协助人员变量")) + BIZ_ASSISTANCE_SWITCH = EnumField("BIZ_ASSISTANCE_SWITCH", _("业务协助开关")) DEFAULT_DB_ADMINISTRATORS = ["admin"] diff --git a/dbm-ui/backend/ticket/models/todo.py b/dbm-ui/backend/ticket/models/todo.py index 77478bd41d..26f5e432dd 100644 --- a/dbm-ui/backend/ticket/models/todo.py +++ b/dbm-ui/backend/ticket/models/todo.py @@ -17,6 +17,8 @@ from backend import env from backend.bk_web.constants import LEN_MIDDLE, LEN_SHORT from backend.bk_web.models import AuditedModel +from backend.configuration.constants import BizSettingsEnum +from backend.configuration.models import BizSettings from backend.ticket.constants import FlowMsgStatus, FlowMsgType, TicketFlowStatus, TodoStatus, TodoType from backend.ticket.tasks.ticket_tasks import send_msg_for_flow @@ -28,6 +30,22 @@ def exist_unfinished(self): return self.filter(status__in=[TodoStatus.TODO, TodoStatus.RUNNING]).exists() def create(self, **kwargs): + assistance_flag = ( + BizSettings.get_setting_value(kwargs["ticket"].bk_biz_id, BizSettingsEnum.BIZ_ASSISTANCE_SWITCH) or False + ) + if assistance_flag: + # 获取业务协助人列表 + biz_facilitators: list = ( + BizSettings.get_setting_value( + bk_biz_id=kwargs["ticket"].bk_biz_id, key=BizSettingsEnum.BIZ_ASSISTANCE_VARS + ) + or [] + ) + operators = kwargs.get("operators", []) + # 过滤掉已经在 operators 中的协助人 + unique_biz_facilitators = [facilitator for facilitator in biz_facilitators if facilitator not in operators] + # 按顺序合并 + kwargs["operators"] = operators + unique_biz_facilitators todo = super().create(**kwargs) send_msg_for_flow.apply_async( kwargs={