feat: 云账号编辑功能 + 通知渠道种子数据 + 修复mock.go编译错误

- 新增 PUT /cloud-accounts/:id 后端端点(UpdateCloudAccount handler + 路由注册)
- 前端 CloudAccountManager 添加编辑弹窗:复用创建表单,凭证留空保持不变
- 修复 scripts/mock.go 编译错误:补充缺失的 generateNotifyChannels 函数(5种通知渠道种子)
- 包含前序未提交的告警通知渠道 CRUD 后端API + AlertManager 通知配置前端UI
This commit is contained in:
attacker committed 2026-06-14 08:16:52 +08:00
1 parent 01a9bebb0c
commit af2e60acd9
9 files changed
+822 -51

No files matched your search

+20
View File
@@ -49,6 +49,9 @@ func generateMockData(db *gorm.DB) error {
if err := generateAlertRules(db); err != nil {
return err
}
if err := generateNotifyChannels(db); err != nil {
return err
}
if err := generatePipelines(db); err != nil {
return err
}
@@ -368,6 +371,23 @@ func generateAlertRules(db *gorm.DB) error {
return nil
}
func generateNotifyChannels(db *gorm.DB) error {
channels := []models.NotifyChannel{
{Name: "运维邮件通知", Type: "email", Config: `{"recipients":["ops@ezops.com","admin@ezops.com"],"subject":"[EZOps告警]"}`, Enabled: true, TestStatus: "success"},
{Name: "短信通知", Type: "sms", Config: `{"phones":["13800138000","13900139000"],"template":"告警:{{alert_name}}"}`, Enabled: true, TestStatus: "success"},
{Name: "钉钉机器人", Type: "dingtalk", Config: `{"webhook":"https://oapi.dingtalk.com/robot/send?access_token=eZOps***","secret":"SEC***","at_all":false}`, Enabled: true, TestStatus: "success"},
{Name: "企业微信机器人", Type: "wechat", Config: `{"webhook":"https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=eZOps***"}`, Enabled: true, TestStatus: "success"},
{Name: "通用Webhook", Type: "webhook", Config: `{"url":"https://api.ezops.com/alerts/webhook","method":"POST","headers":{"Authorization":"Bearer ***"}}`, Enabled: false, TestStatus: "pending"},
}
for i := range channels {
if err := db.Create(&channels[i]).Error; err != nil {
return err
}
}
fmt.Println("Generated notify channels:", len(channels))
return nil
}
func generatePipelines(db *gorm.DB) error {
pipelines := []models.Pipeline{
{Name: "前端构建", Code: "frontend-build", Type: "build", Source: "https://gitlab.com/ezops/frontend", Branch: "main", Enabled: true, Description: "前端项目构建流水线"},