init: EZOps AIOps 智能运维平台

- 前端: React 18 + TypeScript + Vite + Tailwind CSS + shadcn/ui
- 后端: Go + Gin + GORM + JWT (golang-jwt/jwt/v5)
- 功能: 服务器管理、K8s集群、监控告警、CI/CD、自动化运维、审批流程、审计日志
- 文档: 设计文档(ROADMAP/PDD/架构/模块)
This commit is contained in:
attacker committed 2026-06-13 23:09:47 +08:00
commit 7d6674bddd
156 files changed
+45704

No files matched your search

+137
View File
@@ -0,0 +1,137 @@
package models
import (
"time"
"gorm.io/gorm"
)
// AlertRule 告警规则模型
type AlertRule struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:128;not null" json:"name"`
Description string `gorm:"size:500" json:"description"`
Type string `gorm:"size:32;not null" json:"type"` // metric, log, event
Source string `gorm:"size:64;not null" json:"source"` // prometheus, zabbix, custom
Expression string `gorm:"type:text;not null" json:"expression"`
Severity string `gorm:"size:32;default:warning" json:"severity"` // info, warning, critical
Duration int `json:"duration"` // 持续时间(秒)
Enabled bool `gorm:"default:true" json:"enabled"`
Labels string `gorm:"type:text" json:"labels"` // JSON
Annotations string `gorm:"type:text" json:"annotations"` // JSON
NotifyChannels string `gorm:"type:text" json:"notify_channels"` // JSON
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
// TableName 表名
func (AlertRule) TableName() string {
return "alert_rules"
}
// AlertEvent 告警事件模型
type AlertEvent struct {
ID uint `gorm:"primarykey" json:"id"`
RuleID uint `json:"rule_id"`
RuleName string `gorm:"size:128" json:"rule_name"`
Severity string `gorm:"size:32" json:"severity"`
Status string `gorm:"size:32;default:firing" json:"status"` // firing, resolved
Target string `gorm:"size:255" json:"target"`
Message string `gorm:"type:text" json:"message"`
Value float64 `json:"value"`
Labels string `gorm:"type:text" json:"labels"`
StartedAt time.Time `json:"started_at"`
ResolvedAt *time.Time `json:"resolved_at"`
Acknowledged bool `json:"acknowledged"`
AcknowledgedBy *uint `json:"acknowledged_by"`
AcknowledgedAt *time.Time `json:"acknowledged_at"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// 关联
Rule *AlertRule `json:"rule,omitempty"`
}
// TableName 表名
func (AlertEvent) TableName() string {
return "alert_events"
}
// NotifyChannel 通知渠道模型
type NotifyChannel struct {
ID uint `gorm:"primarykey" json:"id"`
Name string `gorm:"size:64;not null" json:"name"`
Type string `gorm:"size:32;not null" json:"type"` // email, sms, webhook, dingtalk, wechat
Config string `gorm:"type:text" json:"config"` // JSON
Enabled bool `gorm:"default:true" json:"enabled"`
TestStatus string `gorm:"size:32" json:"test_status"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
// TableName 表名
func (NotifyChannel) TableName() string {
return "notify_channels"
}
// MetricData 监控指标数据
type MetricData struct {
ID uint `gorm:"primarykey" json:"id"`
ServerID *uint `json:"server_id"`
ClusterID *uint `json:"cluster_id"`
Name string `gorm:"size:64" json:"name"`
Value float64 `json:"value"`
Labels string `gorm:"type:text" json:"labels"`
Timestamp time.Time `json:"timestamp"`
}
// TableName 表名
func (MetricData) TableName() string {
return "metric_data"
}
// CreateAlertRuleRequest 创建告警规则请求
type CreateAlertRuleRequest struct {
Name string `json:"name" binding:"required"`
Description string `json:"description"`
Type string `json:"type" binding:"required,oneof=metric log event"`
Source string `json:"source" binding:"required"`
Expression string `json:"expression" binding:"required"`
Severity string `json:"severity" binding:"omitempty,oneof=info warning critical"`
Duration int `json:"duration"`
Labels string `json:"labels"`
Annotations string `json:"annotations"`
NotifyChannels []string `json:"notify_channels"`
}
// UpdateAlertRuleRequest 更新告警规则请求
type UpdateAlertRuleRequest struct {
Name string `json:"name"`
Description string `json:"description"`
Expression string `json:"expression"`
Severity string `json:"severity" binding:"omitempty,oneof=info warning critical"`
Duration int `json:"duration"`
Enabled *bool `json:"enabled"`
Labels string `json:"labels"`
Annotations string `json:"annotations"`
NotifyChannels []string `json:"notify_channels"`
}
// AlertStats 告警统计
type AlertStats struct {
Total int64 `json:"total"`
Firing int64 `json:"firing"`
Resolved int64 `json:"resolved"`
Critical int64 `json:"critical"`
Warning int64 `json:"warning"`
Info int64 `json:"info"`
TodayCount int64 `json:"today_count"`
WeekCount int64 `json:"week_count"`
}
// AcknowledgeAlertRequest 确认告警请求
type AcknowledgeAlertRequest struct {
Message string `json:"message"`
}