get_expired_thing_notifications.go 965 B

1234567891011121314151617181920212223242526272829303132
  1. package notification
  2. import (
  3. "github.com/gofiber/fiber/v2"
  4. "git.dmitriygnatenko.ru/dima/homethings/internal/helpers"
  5. "git.dmitriygnatenko.ru/dima/homethings/internal/mappers"
  6. )
  7. // @Router /api/v1/things/notifications/expired [get]
  8. // @Success 200 {object} dto.ThingNotificationsExtResponse
  9. // @Failure 400 {object} dto.ErrorResponse
  10. // @Failure 500 {object} dto.ErrorResponse
  11. // @Summary Get expired thing notifications
  12. // @Tags Notifications
  13. // @security APIKey
  14. // @Accept json
  15. // @Produce json
  16. func GetExpiredThingNotificationsHandler(
  17. thingNotificationRepository ThingNotificationRepository,
  18. ) fiber.Handler {
  19. return func(fctx *fiber.Ctx) error {
  20. res, err := thingNotificationRepository.GetExpired(fctx.Context())
  21. if err != nil {
  22. return fiber.NewError(fiber.StatusInternalServerError, err.Error())
  23. }
  24. res = helpers.ApplyLocation(fctx, res)
  25. return fctx.JSON(mappers.ToThingNotificationsExtResponse(res))
  26. }
  27. }