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:
@@ -1,5 +1,7 @@
|
||||
package notification
|
||||
|
||||
import "tm/pkg/response"
|
||||
|
||||
// CreateRequest represents the request to create a notification
|
||||
type NotificationRequest struct {
|
||||
Recipient []string `json:"recipient"`
|
||||
@@ -16,11 +18,31 @@ type NotificationRequest struct {
|
||||
|
||||
// SearchForm represents the form for searching notifications
|
||||
type SearchForm struct {
|
||||
Search *string `query:"q" valid:"optional"`
|
||||
Status NotificationStatus `query:"status" valid:"optional"`
|
||||
|
||||
SortBy *string `query:"sort_by" valid:"optional"`
|
||||
SortOrder *string `query:"sort_order" valid:"optional"`
|
||||
Limit *int `query:"limit" valid:"optional"`
|
||||
Offset *int `query:"offset" valid:"optional"`
|
||||
Status string `query:"status" valid:"optional"`
|
||||
Method string `query:"method" valid:"optional"`
|
||||
EventType string `query:"event_type" valid:"optional"`
|
||||
Type string `query:"type" valid:"optional"`
|
||||
Recipient string `query:"recipient" valid:"optional"`
|
||||
}
|
||||
|
||||
type NotificationListResponse struct {
|
||||
Notifications []*NotificationResponse `json:"notifications"`
|
||||
Meta *response.Meta `json:"meta"`
|
||||
}
|
||||
|
||||
type NotificationResponse struct {
|
||||
ID string `json:"id"`
|
||||
UserID string `json:"user_id"`
|
||||
Title string `json:"title"`
|
||||
Description string `json:"description"`
|
||||
Link *string `json:"link"`
|
||||
Priority string `json:"priority"`
|
||||
Type string `json:"type"`
|
||||
EventType string `json:"event_type"`
|
||||
Status string `json:"status"`
|
||||
Methods map[string]string `json:"methods"`
|
||||
Metadata map[string]any `json:"metadata"`
|
||||
ScheduleAt int64 `json:"schedule_at"`
|
||||
CreatedAt int64 `json:"created_at"`
|
||||
UpdatedAt int64 `json:"updated_at"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user