重构部分枚举, 让models包不依赖其他项目中的包

This commit is contained in:
2025-11-07 21:39:24 +08:00
parent 375af57afe
commit 2796d9bad7
17 changed files with 188 additions and 148 deletions

View File

@@ -4,26 +4,12 @@ import (
"context"
"time"
"go.uber.org/zap/zapcore"
"git.huangwc.com/pig/pig-farm-controller/internal/infra/models"
)
// DefaultTimeFormat 定义了所有通知中统一使用的时间格式。
const DefaultTimeFormat = "2006-01-02 15:04:05"
// NotifierType 定义了通知器的类型。
type NotifierType string
const (
// NotifierTypeSMTP 表示 SMTP 邮件通知器。
NotifierTypeSMTP NotifierType = "邮件"
// NotifierTypeWeChat 表示企业微信通知器。
NotifierTypeWeChat NotifierType = "企业微信"
// NotifierTypeLark 表示飞书通知器。
NotifierTypeLark NotifierType = "飞书"
// NotifierTypeLog 表示日志通知器,作为最终的告警记录渠道。
NotifierTypeLog NotifierType = "日志"
)
// AlarmContent 定义了通知的内容
type AlarmContent struct {
// 通知标题
@@ -31,7 +17,7 @@ type AlarmContent struct {
// 通知信息
Message string
// 通知级别
Level zapcore.Level
Level models.SeverityLevel
// 通知时间
Timestamp time.Time
}
@@ -41,5 +27,5 @@ type Notifier interface {
// Send 发送通知
Send(ctx context.Context, content AlarmContent, toAddr string) error
// Type 返回通知器的类型
Type() NotifierType
Type() models.NotifierType
}