93 lines
4.8 KiB
Go
93 lines
4.8 KiB
Go
package contract
|
|
|
|
import (
|
|
"time"
|
|
|
|
"apskel-pos-be/internal/entities"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// ---- Request contracts ----
|
|
|
|
type SendNotificationRequest struct {
|
|
Title string `json:"title" validate:"required,min=1,max=255"`
|
|
Body string `json:"body" validate:"required"`
|
|
Type string `json:"type,omitempty" validate:"omitempty,max=100"`
|
|
Category string `json:"category,omitempty" validate:"omitempty,max=100"`
|
|
Priority entities.NotificationPriority `json:"priority,omitempty" validate:"omitempty,oneof=low normal high"`
|
|
ImageURL string `json:"image_url,omitempty" validate:"omitempty,max=512"`
|
|
ActionURL string `json:"action_url,omitempty" validate:"omitempty,max=512"`
|
|
NotifiableType string `json:"notifiable_type,omitempty" validate:"omitempty,max=100"`
|
|
NotifiableID *uuid.UUID `json:"notifiable_id,omitempty"`
|
|
Data map[string]interface{} `json:"data,omitempty"`
|
|
ReceiverIDs []uuid.UUID `json:"receiver_ids" validate:"required,min=1"`
|
|
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
|
|
ExpiredAt *time.Time `json:"expired_at,omitempty"`
|
|
}
|
|
|
|
type BroadcastNotificationRequest struct {
|
|
Title string `json:"title" validate:"required,min=1,max=255"`
|
|
Body string `json:"body" validate:"required"`
|
|
Type string `json:"type,omitempty" validate:"omitempty,max=100"`
|
|
Category string `json:"category,omitempty" validate:"omitempty,max=100"`
|
|
Priority entities.NotificationPriority `json:"priority,omitempty" validate:"omitempty,oneof=low normal high"`
|
|
ImageURL string `json:"image_url,omitempty" validate:"omitempty,max=512"`
|
|
ActionURL string `json:"action_url,omitempty" validate:"omitempty,max=512"`
|
|
NotifiableType string `json:"notifiable_type,omitempty" validate:"omitempty,max=100"`
|
|
NotifiableID *uuid.UUID `json:"notifiable_id,omitempty"`
|
|
Data map[string]interface{} `json:"data,omitempty"`
|
|
ScheduledAt *time.Time `json:"scheduled_at,omitempty"`
|
|
ExpiredAt *time.Time `json:"expired_at,omitempty"`
|
|
}
|
|
|
|
type ListNotificationsRequest struct {
|
|
Page int `form:"page" validate:"min=1"`
|
|
Limit int `form:"limit" validate:"min=1,max=100"`
|
|
IsRead *bool `form:"is_read"`
|
|
}
|
|
|
|
// ---- Response contracts ----
|
|
|
|
type NotificationResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
Title string `json:"title"`
|
|
Body string `json:"body"`
|
|
Type string `json:"type"`
|
|
Category string `json:"category"`
|
|
Priority entities.NotificationPriority `json:"priority"`
|
|
ImageURL string `json:"image_url"`
|
|
ActionURL string `json:"action_url"`
|
|
NotifiableType string `json:"notifiable_type"`
|
|
NotifiableID *uuid.UUID `json:"notifiable_id"`
|
|
Data map[string]interface{} `json:"data"`
|
|
ScheduledAt *time.Time `json:"scheduled_at"`
|
|
SentAt *time.Time `json:"sent_at"`
|
|
ExpiredAt *time.Time `json:"expired_at"`
|
|
CreatedBy *uuid.UUID `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type NotificationReceiverResponse struct {
|
|
ID uuid.UUID `json:"id"`
|
|
NotificationID uuid.UUID `json:"notification_id"`
|
|
UserID uuid.UUID `json:"user_id"`
|
|
IsRead bool `json:"is_read"`
|
|
ReadAt *time.Time `json:"read_at"`
|
|
IsDeleted bool `json:"is_deleted"`
|
|
DeletedAt *time.Time `json:"deleted_at"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
Notification *NotificationResponse `json:"notification,omitempty"`
|
|
}
|
|
|
|
type ListNotificationsResponse struct {
|
|
Notifications []*NotificationReceiverResponse `json:"notifications"`
|
|
TotalCount int64 `json:"total_count"`
|
|
UnreadCount int64 `json:"unread_count"`
|
|
Page int `json:"page"`
|
|
Limit int `json:"limit"`
|
|
TotalPages int `json:"total_pages"`
|
|
}
|