feat: notifications

This commit is contained in:
2025-11-30 19:24:51 +08:00
parent 4550720cbb
commit 4a6c214709
14 changed files with 492 additions and 37 deletions

View File

@@ -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
}