Enhance Notification Management with New Endpoints and Response Structures

- Added new endpoints for retrieving notifications for both admins and users, improving the flexibility of the notification system.
- Implemented query parameters for filtering notifications by status, method, event type, type, and recipient, enhancing usability.
- Introduced new response structures for notifications, including pagination information, to provide better data handling in API responses.
- Updated API documentation with Swagger comments for the new endpoints and response formats, ensuring clarity for API consumers.
- Refactored notification handling logic to support the new features, promoting a more robust notification management system.
This commit is contained in:
n.nakhostin
2025-09-20 17:41:21 +03:30
parent ab6eb3b3ed
commit 19cd346b1c
13 changed files with 1637 additions and 16 deletions
+46
View File
@@ -116,3 +116,49 @@ func (nm *NotificationMethods) GetMethodValue(eventType EventType) string {
func (nr *NotificationRequest) IsImmediate() bool {
return nr.ScheduledAt == 0
}
// NotificationItem represents a single notification in the list response
type NotificationItem struct {
ID string `json:"id"`
UserID string `json:"user_id"`
Title string `json:"title"`
Message string `json:"message"`
Link string `json:"link"`
Image string `json:"image"`
Type string `json:"type"`
Priority string `json:"priority"`
EventType string `json:"event_type"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Methods map[string]string `json:"methods"`
Metadata map[string]any `json:"metadata"`
Status string `json:"status"`
ScheduledAt int64 `json:"scheduled_at"`
IsScheduled bool `json:"is_scheduled"`
}
// NotificationListResponse represents the response from getting notifications list
type NotificationListResponse struct {
Data []NotificationItem `json:"data"`
Pagination PaginationInfo `json:"pagination"`
}
// PaginationInfo represents pagination information in responses
type PaginationInfo struct {
Total int `json:"total"`
Count int `json:"count"`
PerPage int `json:"per_page"`
CurrentPage int `json:"current_page"`
TotalPages int `json:"total_pages"`
}
// GetNotificationsRequest represents the request parameters for getting notifications
type GetNotificationsRequest struct {
Status string `json:"status,omitempty" valid:"optional"`
Method string `json:"method,omitempty" valid:"optional"`
EventType string `json:"event_type,omitempty" valid:"optional"`
Type string `json:"type,omitempty" valid:"optional"`
UserID string `json:"user_id,omitempty" valid:"optional"`
Page int `json:"page,omitempty" valid:"optional"`
PerPage int `json:"per_page,omitempty" valid:"optional"`
}