26 lines
548 B
Go
26 lines
548 B
Go
package handlers
|
|
|
|
import (
|
|
"gorm.io/gorm"
|
|
|
|
"everypublish/server/internal/models"
|
|
)
|
|
|
|
// Notify 写入站内通知(批量用户)
|
|
func Notify(db *gorm.DB, wsid uint64, userIDs []uint64, kind, title, content string) error {
|
|
if len(userIDs) == 0 {
|
|
return nil
|
|
}
|
|
rows := make([]models.Notification, 0, len(userIDs))
|
|
for _, uid := range userIDs {
|
|
rows = append(rows, models.Notification{
|
|
WorkspaceID: wsid,
|
|
UserID: uid,
|
|
Kind: kind,
|
|
Title: title,
|
|
Content: content,
|
|
})
|
|
}
|
|
return db.Create(&rows).Error
|
|
}
|