发送通知时写入数据库
This commit is contained in:
@@ -8,6 +8,16 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// NotificationStatus 定义了通知发送尝试的状态枚举。
|
||||
type NotificationStatus string
|
||||
|
||||
const (
|
||||
NotificationStatusTest NotificationStatus = "测试通知" // 测试用通知
|
||||
NotificationStatusSuccess NotificationStatus = "发送成功" // 通知已成功发送
|
||||
NotificationStatusFailed NotificationStatus = "发送失败" // 通知发送失败
|
||||
NotificationStatusSkipped NotificationStatus = "已跳过" // 通知因某些原因被跳过(例如:用户未配置联系方式)
|
||||
)
|
||||
|
||||
// Notification 表示已发送或尝试发送的通知记录。
|
||||
type Notification struct {
|
||||
gorm.Model
|
||||
@@ -26,8 +36,8 @@ type Notification struct {
|
||||
AlarmTimestamp time.Time `gorm:"primaryKey;not null" json:"alarm_timestamp"`
|
||||
// ToAddress 接收地址 (例如:邮箱地址, 企业微信ID, 日志标识符)
|
||||
ToAddress string `gorm:"type:varchar(255);not null" json:"to_address"`
|
||||
// Status 通知发送尝试的状态 (例如:"success", "failed", "pending")
|
||||
Status string `gorm:"type:varchar(20);not null;default:'pending'" json:"status"`
|
||||
// Status 通知发送尝试的状态 (例如:"待发送", "发送成功", "发送失败", "已跳过")
|
||||
Status NotificationStatus `gorm:"type:varchar(20);not null;default:'待发送'" json:"status"`
|
||||
// ErrorMessage 如果通知发送失败,此字段存储错误信息
|
||||
ErrorMessage string `gorm:"type:text" json:"error_message"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user