package notification import ( "github.com/asaskevich/govalidator" "github.com/labstack/echo/v4" "tm/pkg/logger" "tm/pkg/response" ) // NotificationHandler handles HTTP requests for notification operations type NotificationHandler struct { service Service logger logger.Logger } // NewNotificationHandler creates a new notification handler func NewHandler(service Service, logger logger.Logger) *NotificationHandler { return &NotificationHandler{ service: service, logger: logger, } } // CreateNotification creates a new notification // @Summary Create a new notification // @Description Create a new notification with the provided information // @Tags Admin-Notification // @Accept json // @Produce json // @Param notification body NotificationRequest true "Notification information" // @Success 201 {object} response.APIResponse "Notification created successfully" // @Failure 400 {object} response.APIResponse // @Failure 500 {object} response.APIResponse // @Router /admin/v1/notifications [post] func (h *NotificationHandler) Send(c echo.Context) error { var req NotificationRequest if err := c.Bind(&req); err != nil { return response.BadRequest(c, "Invalid request format", err.Error()) } // Validate request if valid, err := govalidator.ValidateStruct(req); !valid { return response.ValidationError(c, "Validation failed", err.Error()) } // Send notification if err := h.service.Send(c.Request().Context(), &req); err != nil { return response.InternalServerError(c, "Failed to send notification") } return response.Created(c, nil, "Notification sent successfully") }