feat: 添加核心金融模型、通知模型以及路由和通知仓库的基础结构

This commit is contained in:
2026-01-28 08:38:18 +08:00
parent 5d834204dd
commit 0414401ada
4 changed files with 24 additions and 59 deletions

View File

@@ -3,6 +3,7 @@ package repository
import (
"errors"
"fmt"
"time"
"accounting-app/internal/models"
@@ -119,20 +120,12 @@ func (r *NotificationRepository) MarkAsRead(userID uint, id uint) error {
// MarkAllAsRead marks all notifications as read for a user
func (r *NotificationRepository) MarkAllAsRead(userID uint) error {
<<<<<<< HEAD
return r.db.Model(&models.Notification{}).
Where("user_id = ? AND is_read = ?", userID, false).
Updates(map[string]interface{}{
"is_read": true,
"read_at": time.Now(),
}).Error
=======
if err := r.db.Model(&models.Notification{}).
return r.db.Model(&models.Notification{}).
Where("user_id = ? AND is_read = ?", userID, false).
Update("is_read", true).Error; err != nil {
return fmt.Errorf("failed to mark all notifications as read: %w", err)
}
return nil
Updates(map[string]interface{}{
"is_read": true,
"read_at": time.Now(),
}).Error
}
// Delete deletes a notification by its ID
@@ -156,5 +149,4 @@ func (r *NotificationRepository) GetUnreadCount(userID uint) (int64, error) {
return 0, fmt.Errorf("failed to count unread notifications: %w", err)
}
return count, nil
>>>>>>> 2dc66d478cbe3aafaae601f0939ab448b690365e
}