hybrid pagination
This commit is contained in:
@@ -87,11 +87,16 @@ func (h *NotificationHandler) GetNotifications(c echo.Context) error {
|
||||
return response.ValidationError(c, err.Error(), "")
|
||||
}
|
||||
|
||||
pagination := response.NewPagination(c)
|
||||
pagination, err := response.NewPagination(c)
|
||||
if err != nil {
|
||||
return response.PaginationBadRequest(c, err)
|
||||
}
|
||||
|
||||
// Call service
|
||||
notifications, err := h.service.GetNotifications(c.Request().Context(), form, pagination)
|
||||
if err != nil {
|
||||
if response.IsListPaginationError(err) {
|
||||
return response.PaginationBadRequest(c, err)
|
||||
}
|
||||
return response.InternalServerError(c, "Failed to get notifications")
|
||||
}
|
||||
|
||||
@@ -141,11 +146,16 @@ func (h *NotificationHandler) AdminNotifications(c echo.Context) error {
|
||||
form.Recipient = userID
|
||||
form.Status = "sent"
|
||||
|
||||
pagination := response.NewPagination(c)
|
||||
pagination, err := response.NewPagination(c)
|
||||
if err != nil {
|
||||
return response.PaginationBadRequest(c, err)
|
||||
}
|
||||
|
||||
// Call service
|
||||
notifications, err := h.service.GetNotifications(c.Request().Context(), form, pagination)
|
||||
if err != nil {
|
||||
if response.IsListPaginationError(err) {
|
||||
return response.PaginationBadRequest(c, err)
|
||||
}
|
||||
return response.InternalServerError(c, "Failed to get notifications")
|
||||
}
|
||||
|
||||
@@ -254,12 +264,16 @@ func (h *NotificationHandler) CustomerNotifications(c echo.Context) error {
|
||||
form.Recipient = userID
|
||||
form.Status = "sent"
|
||||
|
||||
pagination := response.NewPagination(c)
|
||||
pagination, err := response.NewPagination(c)
|
||||
if err != nil {
|
||||
return response.PaginationBadRequest(c, err)
|
||||
}
|
||||
|
||||
// Call service
|
||||
notifications, err := h.service.GetNotifications(c.Request().Context(), form, pagination)
|
||||
if err != nil {
|
||||
// Log the actual error for debugging
|
||||
if response.IsListPaginationError(err) {
|
||||
return response.PaginationBadRequest(c, err)
|
||||
}
|
||||
c.Logger().Error("GetNotifications failed", map[string]interface{}{
|
||||
"error": err.Error(),
|
||||
"status": form.Status,
|
||||
|
||||
Reference in New Issue
Block a user