backend/pkg/notification/domain/entity/notification_event.go

27 lines
1.4 KiB
Go
Raw Normal View History

2025-11-17 09:31:58 +00:00
package entity
import (
"backend/pkg/notification/domain/notification"
"time"
"github.com/gocql/gocql"
)
// NotificationEvent represents an event that triggers a notification.
type NotificationEvent struct {
EventID gocql.UUID `db:"event_id" partition_key:"true"` // 事件 ID
EventType string `db:"event_type"` // POST_PUBLISHED / COMMENT_ADDED / MENTIONED ...
ActorUID string `db:"actor_uid"` // 觸發者 UID
ObjectType string `db:"object_type"` // POST / COMMENT / USER ...
ObjectID string `db:"object_id"` // 對應物件 IDpost_id 等)
Title string `db:"title"` // 顯示用標題
Body string `db:"body"` // 顯示用內容 / 摘要
Payload string `db:"payload"` // JSON string額外欄位例如 {"postId": "..."}
Priority notification.NotifyPriority `db:"priority"` // 1=critical, 2=high, 3=normal, 4=low
CreatedAt time.Time `db:"created_at"` // 事件時間(方便做 cross table 查詢)
}
func (ue *NotificationEvent) TableName() string {
return "notification_event"
}