mirror of
https://github.com/StarFleetCPTN/GoMFT.git
synced 2026-10-24 06:50:26 +02:00
feat: Enhance notifications and pagination functionality
- Implemented pagination for user notifications, allowing users to navigate through their notifications more efficiently. - Updated the notifications page to display the total count of notifications and provide controls for adjusting the number of notifications shown per page. - Added backend support for fetching paginated notifications and counting total notifications for users. - Improved the user interface for notifications, including a new layout and additional help sections to guide users on managing their notifications.
This commit is contained in:
1 parent
db6259f8a3
commit
3140d9e143
11 files changed
+1187
-895
No files matched your search
@@ -38,6 +38,20 @@ func (db *DB) GetUserNotifications(userID uint, limit int) ([]UserNotification,
|
||||
return notifications, result.Error
|
||||
}
|
||||
|
||||
// GetUserNotificationCount returns the total count of notifications for a user
|
||||
func (db *DB) GetUserNotificationCount(userID uint) (int64, error) {
|
||||
var count int64
|
||||
result := db.Model(&UserNotification{}).Where("user_id = ?", userID).Count(&count)
|
||||
return count, result.Error
|
||||
}
|
||||
|
||||
// GetPaginatedUserNotifications returns paginated notifications for a user
|
||||
func (db *DB) GetPaginatedUserNotifications(userID uint, offset, limit int) ([]UserNotification, error) {
|
||||
var notifications []UserNotification
|
||||
result := db.Where("user_id = ?", userID).Order("created_at DESC").Offset(offset).Limit(limit).Find(¬ifications)
|
||||
return notifications, result.Error
|
||||
}
|
||||
|
||||
// GetUnreadNotificationCount returns the count of unread notifications for a user
|
||||
func (db *DB) GetUnreadNotificationCount(userID uint) (int64, error) {
|
||||
var count int64
|
||||
|
||||
Reference in new issue
Block a user