Skip to content

Commit b1c072b

Browse files
committed
feat(backend): 单据通知适配器,接入bkchat TencentBlueKing#8755
1 parent fc16bd7 commit b1c072b

File tree

34 files changed

+856
-325
lines changed

34 files changed

+856
-325
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
4+
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
5+
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at https://opensource.org/licenses/MIT
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
specific language governing permissions and limitations under the License.
10+
"""
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
4+
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
5+
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at https://opensource.org/licenses/MIT
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
specific language governing permissions and limitations under the License.
10+
"""
11+
12+
from django.utils.translation import ugettext_lazy as _
13+
14+
from ..base import BaseApi
15+
from ..domains import BKCHAT_APIGW_DOMAIN
16+
17+
18+
class _BkChatApi(BaseApi):
19+
MODULE = _("蓝鲸信息流")
20+
BASE = BKCHAT_APIGW_DOMAIN
21+
22+
def __init__(self):
23+
self.send_msg = self.generate_data_api(
24+
method="POST",
25+
url="dbm_ticket_send/",
26+
description=_("dbm消息发送"),
27+
)
28+
29+
30+
BkChatApi = _BkChatApi()

dbm-ui/backend/components/cmsi/client.py

-12
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
from django.utils.translation import ugettext_lazy as _
1313

14-
from blue_krill.data_types.enum import EnumField, StructuredEnum
15-
1614
from ..base import BaseApi
1715
from ..domains import CMSI_APIGW_DOMAIN
1816

@@ -21,16 +19,6 @@ class _CmsiApi(BaseApi):
2119
MODULE = _("消息管理")
2220
BASE = CMSI_APIGW_DOMAIN
2321

24-
class MsgType(str, StructuredEnum):
25-
SMS = EnumField("sms", _("短信"))
26-
WEIXIN = EnumField("weixin", _("微信"))
27-
MAIL = EnumField("mail", _("邮件"))
28-
VOICE = EnumField("voice", _("语音"))
29-
RTX = EnumField("rtx", _("企业微信"))
30-
WECOM_ROBOT = EnumField("wecom_robot", _("企业微信机器人"))
31-
# 未知发送类型,配置此type一般用于跳过消息发送
32-
UNKNOWN = EnumField("unknown", _("未知"))
33-
3422
def __init__(self):
3523
self.send_msg = self.generate_data_api(
3624
method="POST",

dbm-ui/backend/components/cmsi/handler.py

-66
This file was deleted.

dbm-ui/backend/components/domains.py

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
ESB_APIGW_DOMAIN = env.ESB_APIGW_DOMAIN or ESB_DOMAIN_TPL.format("esb")
2424
USER_MANAGE_APIGW_DOMAIN = env.USER_MANAGE_APIGW_DOMAIN or ESB_DOMAIN_TPL.format("usermanage")
2525
CMSI_APIGW_DOMAIN = env.CMSI_APIGW_DOMAIN or ESB_DOMAIN_TPL.format("cmsi")
26+
BKCHAT_APIGW_DOMAIN = env.BKCHAT_APIGW_DOMAIN
2627
ITSM_APIGW_DOMAIN = env.ITSM_APIGW_DOMAIN or ESB_DOMAIN_TPL.format("itsm")
2728
BKLOG_APIGW_DOMAIN = env.BKLOG_APIGW_DOMAIN or ESB_DOMAIN_TPL.format("bk_log")
2829
BKNODEMAN_APIGW_DOMAIN = env.BKNODEMAN_APIGW_DOMAIN or ESB_DOMAIN_TPL.format("nodeman")

dbm-ui/backend/configuration/constants.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,12 @@ class BizSettingsEnum(str, StructuredEnum):
126126

127127
OPEN_AREA_VARS = EnumField("OPEN_AREA_VARS", _("开区模板的渲染变量"))
128128
INDEPENDENT_HOSTING_DB_TYPES = EnumField("INDEPENDENT_HOSTING_DB_TYPES", _("独立托管机器的数据库类型"))
129-
# TODO: 后续待删除
129+
# TODO: SKIP_GRAMMAR_CHECK 后续待删除
130130
SKIP_GRAMMAR_CHECK = EnumField("SKIP_GRAMMAR_CHECK", _("是否跳过语义检查"))
131131
SQL_IMPORT_FORCE_ITSM = EnumField("SQL_IMPORT_FORCE_ITSM", _("是否变更SQL强制需要审批流"))
132132
BIZ_ASSISTANCE_VARS = EnumField("BIZ_ASSISTANCE_VARS", _("业务协助人员变量"))
133133
BIZ_ASSISTANCE_SWITCH = EnumField("BIZ_ASSISTANCE_SWITCH", _("业务协助开关"))
134+
NOTIFY_CONFIG = EnumField("NOTIFY_CONFIG", _("业务通知渠道配置"))
134135

135136

136137
DEFAULT_DB_ADMINISTRATORS = ["admin"]
+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
4+
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
5+
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at https://opensource.org/licenses/MIT
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
specific language governing permissions and limitations under the License.
10+
"""
11+
12+
from .handlers import NotifyAdapter, send_msg
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
4+
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
5+
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at https://opensource.org/licenses/MIT
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
specific language governing permissions and limitations under the License.
10+
"""
11+
from django.utils.translation import ugettext as _
12+
13+
from backend.ticket.constants import TicketStatus
14+
from blue_krill.data_types.enum import EnumField, StructuredEnum
15+
16+
17+
class MsgType(str, StructuredEnum):
18+
SMS = EnumField("sms", _("短信"))
19+
WEIXIN = EnumField("weixin", _("微信"))
20+
MAIL = EnumField("mail", _("邮件"))
21+
VOICE = EnumField("voice", _("语音"))
22+
RTX = EnumField("rtx", _("企业微信"))
23+
WECOM_ROBOT = EnumField("wecom_robot", _("企业微信机器人"))
24+
# 未知发送类型,配置此type一般用于跳过消息发送
25+
UNKNOWN = EnumField("unknown", _("未知"))
26+
27+
28+
# 默认通知:微信和邮件
29+
DEFAULT_BIZ_NOTIFY_CONFIG = {
30+
status: {MsgType.RTX.value: True, MsgType.MAIL.value: True} for status in TicketStatus.get_values()
31+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# -*- coding: utf-8 -*-
2+
"""
3+
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available.
4+
Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved.
5+
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at https://opensource.org/licenses/MIT
7+
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
8+
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
9+
specific language governing permissions and limitations under the License.
10+
"""
11+
12+
13+
from django.utils.translation import ugettext_lazy as _
14+
15+
from ..exceptions import CoreBaseException
16+
17+
18+
class NotifyBaseException(CoreBaseException):
19+
MESSAGE = _("通知失败")

0 commit comments

Comments
 (0)