- 新增 platform_notification_channels 表管理通知渠道(钉钉/企微机器人)
- 新增通知渠道管理页面,支持创建、编辑、测试、删除
- 定时任务增加通知渠道选择和企微应用选择
- 脚本执行支持返回值(result变量),自动发送到配置的渠道
- 调度器执行脚本后根据配置自动发送通知
使用方式:
1. 在「通知渠道」页面为租户配置钉钉/企微机器人
2. 创建定时任务时选择通知渠道
3. 脚本中设置 result = {'content': '内容', 'title': '标题'}
4. 任务执行后自动发送到配置的渠道
This commit is contained in:
@@ -9,6 +9,7 @@ from .logs import PlatformLog
|
||||
from .alert import AlertRule, AlertRecord, NotificationChannel
|
||||
from .pricing import ModelPricing, TenantBilling
|
||||
from .scheduled_task import ScheduledTask, TaskLog, ScriptVar, Secret
|
||||
from .notification_channel import NotificationChannel
|
||||
|
||||
__all__ = [
|
||||
"Tenant",
|
||||
@@ -29,5 +30,6 @@ __all__ = [
|
||||
"ScheduledTask",
|
||||
"TaskLog",
|
||||
"ScriptVar",
|
||||
"Secret"
|
||||
"Secret",
|
||||
"NotificationChannel"
|
||||
]
|
||||
|
||||
20
backend/app/models/notification_channel.py
Normal file
20
backend/app/models/notification_channel.py
Normal file
@@ -0,0 +1,20 @@
|
||||
"""通知渠道模型"""
|
||||
from datetime import datetime
|
||||
from sqlalchemy import Column, Integer, String, Enum, Boolean, DateTime
|
||||
from ..database import Base
|
||||
|
||||
|
||||
class NotificationChannel(Base):
|
||||
"""通知渠道表"""
|
||||
__tablename__ = "platform_notification_channels"
|
||||
|
||||
id = Column(Integer, primary_key=True, autoincrement=True)
|
||||
tenant_id = Column(String(50), nullable=False)
|
||||
channel_name = Column(String(100), nullable=False)
|
||||
channel_type = Column(Enum('dingtalk_bot', 'wecom_bot'), nullable=False)
|
||||
webhook_url = Column(String(500), nullable=False)
|
||||
description = Column(String(255))
|
||||
is_enabled = Column(Boolean, default=True)
|
||||
|
||||
created_at = Column(DateTime, default=datetime.now)
|
||||
updated_at = Column(DateTime, default=datetime.now, onupdate=datetime.now)
|
||||
@@ -40,6 +40,10 @@ class ScheduledTask(Base):
|
||||
alert_on_failure = Column(Boolean, default=False)
|
||||
alert_webhook = Column(String(500))
|
||||
|
||||
# 通知配置
|
||||
notify_channels = Column(JSON) # 通知渠道ID列表
|
||||
notify_wecom_app_id = Column(Integer) # 企微应用ID
|
||||
|
||||
# 状态
|
||||
is_enabled = Column(Boolean, default=True)
|
||||
last_run_at = Column(DateTime)
|
||||
|
||||
Reference in New Issue
Block a user