63 lines
2.8 KiB
Go
63 lines
2.8 KiB
Go
package model
|
||
|
||
// Notification 通知数据模型
|
||
type Notification struct {
|
||
ID int64 `json:"id" gorm:"primaryKey;column:id"`
|
||
UserID int64 `json:"user_id" gorm:"column:user_id;not null;index"`
|
||
StarID int64 `json:"star_id" gorm:"column:star_id;not null"`
|
||
Type string `json:"type" gorm:"column:type;not null;size:20"`
|
||
Title string `json:"title" gorm:"column:title;not null;size:200"`
|
||
Content string `json:"content" gorm:"column:content;size:500"`
|
||
Data string `json:"data" gorm:"column:data;type:jsonb"`
|
||
IsRead bool `json:"is_read" gorm:"column:is_read;not null;default:false"`
|
||
IsDeleted bool `json:"is_deleted" gorm:"column:is_deleted;not null;default:false"`
|
||
CreatedAt int64 `json:"created_at" gorm:"column:created_at;not null"`
|
||
ReadAt int64 `json:"read_at" gorm:"column:read_at"`
|
||
}
|
||
|
||
// TableName 表名
|
||
func (Notification) TableName() string {
|
||
return "public.notifications"
|
||
}
|
||
|
||
// NotificationStats 通知统计模型
|
||
type NotificationStats struct {
|
||
UserID int64 `json:"user_id" gorm:"primaryKey;column:user_id"`
|
||
StarID int64 `json:"star_id" gorm:"primaryKey;column:star_id"`
|
||
LikeUnreadCount int `json:"like_unread_count" gorm:"column:like_unread_count;not null;default:0"`
|
||
SystemUnreadCount int `json:"system_unread_count" gorm:"column:system_unread_count;not null;default:0"`
|
||
ActivityUnreadCount int `json:"activity_unread_count" gorm:"column:activity_unread_count;not null;default:0"`
|
||
TotalUnreadCount int `json:"total_unread_count" gorm:"column:total_unread_count;not null;default:0"`
|
||
UpdatedAt int64 `json:"updated_at" gorm:"column:updated_at;not null"`
|
||
}
|
||
|
||
// TableName 表名
|
||
func (NotificationStats) TableName() string {
|
||
return "public.notification_stats"
|
||
}
|
||
|
||
// ActorPreview 列表层聚合时的 actor 预览
|
||
type ActorPreview struct {
|
||
UserID int64 `json:"user_id"`
|
||
Nickname string `json:"nickname"`
|
||
Avatar string `json:"avatar"`
|
||
LikedAt int64 `json:"liked_at"`
|
||
}
|
||
|
||
// AggregatedNotification 聚合查询结果(type=like 时返回)
|
||
type AggregatedNotification struct {
|
||
ID int64 `json:"id"`
|
||
UserID int64 `json:"user_id"`
|
||
StarID int64 `json:"star_id"`
|
||
Type string `json:"type"`
|
||
Title string `json:"title"`
|
||
Content string `json:"content"`
|
||
TargetID int64 `json:"target_id"`
|
||
IsRead bool `json:"is_read"`
|
||
CreatedAt int64 `json:"created_at"`
|
||
ReadAt int64 `json:"read_at"`
|
||
TotalCount int32 `json:"total_count"`
|
||
Actors []ActorPreview `json:"actors"`
|
||
Data string `json:"data"`
|
||
}
|