get_expired_thing_notifications.go 1014 B

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