Enhance notification search functionality and update API documentation

- Added `search` and `q` query parameters to the `SearchForm` for improved notification searching capabilities.
- Implemented `ResolvedSearch` method to prioritize search term resolution from the new parameters.
- Updated `GetByUserID` repository method to support searching notifications by title and message using regex.
- Enhanced logging in the `GetNotifications` service method to include search parameters.
- Updated Swagger documentation to reflect the new search parameters for the notification API.

This update improves the user experience by allowing more flexible and efficient searching of notifications.
This commit is contained in:
Mazyar
2026-06-11 01:33:47 +03:30
parent 4f05516fc2
commit f16f9fb5a9
4 changed files with 39 additions and 9 deletions
+4 -1
View File
@@ -183,7 +183,10 @@ func (s *notificationService) persistNotification(ctx context.Context, recipient
}
func (s *notificationService) GetNotifications(ctx context.Context, req *SearchForm, pagination *response.Pagination) (*NotificationListResponse, error) {
search := req.ResolvedSearch()
s.logger.Info("Getting notifications", map[string]interface{}{
"search": search,
"status": req.Status,
"method": req.Method,
"event_type": req.EventType,
@@ -195,7 +198,7 @@ func (s *notificationService) GetNotifications(ctx context.Context, req *SearchF
"offset": pagination.Offset,
})
page, err := s.repository.GetByUserID(ctx, req.Recipient, req.Status, req.Seen, req.Priority, req.EventType, req.Type, pagination)
page, err := s.repository.GetByUserID(ctx, req.Recipient, search, req.Status, req.Seen, req.Priority, req.EventType, req.Type, pagination)
if err != nil {
s.logger.Error("Failed to get notifications", map[string]interface{}{
"error": err.Error(),