mirror of
https://github.com/wgh136/nysoure.git
synced 2025-12-16 23:51:15 +00:00
feat: notifications
This commit is contained in:
@@ -2,8 +2,9 @@ package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"gorm.io/gorm"
|
||||
"nysoure/server/model"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func CreateUser(username string, hashedPassword []byte) (model.User, error) {
|
||||
@@ -132,3 +133,15 @@ func DeleteUser(id uint) error {
|
||||
}
|
||||
return db.Delete(&model.User{}, id).Error
|
||||
}
|
||||
|
||||
func ResetUserNotificationsCount(userID uint) error {
|
||||
return db.Model(&model.User{}).Where("id = ?", userID).Update("unread_notifications_count", 0).Error
|
||||
}
|
||||
|
||||
func GetUserNotificationCount(userID uint) (uint, error) {
|
||||
var count uint
|
||||
if err := db.Model(&model.User{}).Where("id = ?", userID).Select("unread_notifications_count").Scan(&count).Error; err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return count, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user