This commit is contained in:
parent
500bf48295
commit
f3a139b809
6 changed files with 103 additions and 34 deletions
41
storage-new/models/Notification.go
Normal file
41
storage-new/models/Notification.go
Normal file
|
@ -0,0 +1,41 @@
|
|||
package models
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
|
||||
"gorm.io/gen"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Notifications inform users of inbound events
|
||||
// happening to their content
|
||||
type Notification struct {
|
||||
gorm.Model
|
||||
ForUser User // The user the notification is for
|
||||
ForUserId string
|
||||
SourceNote *Note // The note where the notification originates from
|
||||
SourceNoteId sql.NullString
|
||||
SourceUser *User // The user causing the notification
|
||||
SourceUserId sql.NullString
|
||||
Cause NotificationCauseType // What the cause of the notification is
|
||||
ViewedState NotificationViewedState // What the last known state of the notification is
|
||||
}
|
||||
|
||||
type INotification interface {
|
||||
// Update a given set of notifications to a given viewed state
|
||||
//
|
||||
// UPDATE @@table SET viewed_state = @state WHERE id IN @id
|
||||
SetState(state NotificationViewedState, ids ...uint) error
|
||||
|
||||
// Get the lastest count amount of notifications with a given offset for a user
|
||||
//
|
||||
// SELECT * FROM @@table WHERE for_user_id = @id
|
||||
// ORDER BY id DESC
|
||||
// {{if count > 0 }}
|
||||
// LIMIT @count
|
||||
// {{else}}
|
||||
// LIMIT 20
|
||||
// {{end}}
|
||||
// OFFSET @offset
|
||||
GetLatestWithOffset(userId string, count uint, offset uint) ([]gen.T, error)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue