From 8676f0cbd020cd230cd675283825d5fe8062c47b Mon Sep 17 00:00:00 2001 From: iSecloud <869820505@qq.com> Date: Thu, 26 Sep 2024 10:34:29 +0800 Subject: [PATCH] =?UTF-8?q?fix(backend):=20=E5=8F=98=E6=9B=B4SQL=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E4=B8=9A=E5=8A=A1=E5=BC=BA=E5=88=B6=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=20#7138?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dbm-ui/backend/configuration/constants.py | 1 + .../backend/ticket/builders/mysql/mysql_import_sqlfile.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/dbm-ui/backend/configuration/constants.py b/dbm-ui/backend/configuration/constants.py index 317f834f68..a10e19be90 100644 --- a/dbm-ui/backend/configuration/constants.py +++ b/dbm-ui/backend/configuration/constants.py @@ -108,6 +108,7 @@ class BizSettingsEnum(str, StructuredEnum): INDEPENDENT_HOSTING_DB_TYPES = EnumField("INDEPENDENT_HOSTING_DB_TYPES", _("独立托管机器的数据库类型")) # TODO: 后续待删除 SKIP_GRAMMAR_CHECK = EnumField("SKIP_GRAMMAR_CHECK", _("是否跳过语义检查")) + SQL_IMPORT_FORCE_ITSM = EnumField("SQL_IMPORT_FORCE_ITSM", _("是否变更SQL强制需要审批流")) DEFAULT_DB_ADMINISTRATORS = ["admin"] diff --git a/dbm-ui/backend/ticket/builders/mysql/mysql_import_sqlfile.py b/dbm-ui/backend/ticket/builders/mysql/mysql_import_sqlfile.py index 14a718aeca..9bfb2960b7 100644 --- a/dbm-ui/backend/ticket/builders/mysql/mysql_import_sqlfile.py +++ b/dbm-ui/backend/ticket/builders/mysql/mysql_import_sqlfile.py @@ -16,7 +16,8 @@ from backend import env from backend.components.sql_import.client import SQLSimulationApi -from backend.configuration.constants import DBType +from backend.configuration.constants import BizSettingsEnum, DBType +from backend.configuration.models import BizSettings from backend.db_services.mysql.sql_import.constants import SQLExecuteTicketMode from backend.db_services.mysql.sql_import.handlers import SQLHandler from backend.flow.engine.bamboo.engine import BambooEngine @@ -113,6 +114,10 @@ class MysqlSqlImportFlowBuilder(BaseMySQLTicketFlowBuilder): @property def need_itsm(self): + # 业务强制需要审批流 + force_need_itsm = BizSettings.get_setting_value(self.ticket.bk_biz_id, BizSettingsEnum.SQL_IMPORT_FORCE_ITSM) + if force_need_itsm: + return True # 非高危的SQL变更单据,不需要审批节点 grammar_check_info = self.ticket.details["grammar_check_info"].values() high_risk = [check["highrisk_warnings"] for check in grammar_check_info if check["highrisk_warnings"]]