Docker/Voltaserve/api/router/notification_router.go
2024-04-17 20:22:30 +02:00

41 lines
826 B
Go

package router
import (
"voltaserve/service"
"github.com/gofiber/fiber/v2"
)
type NotificationRouter struct {
notificationSvc *service.NotificationService
}
func NewNotificationRouter() *NotificationRouter {
return &NotificationRouter{
notificationSvc: service.NewNotificationService(),
}
}
func (r *NotificationRouter) AppendRoutes(g fiber.Router) {
g.Get("/", r.GetAll)
}
// GetAll godoc
//
// @Summary Get notifications
// @Description Get notifications
// @Tags Notifications
// @Id notification_get_all
// @Produce json
// @Success 200 {array} service.Notification
// @Failure 500
// @Router /notifications [get]
func (r *NotificationRouter) GetAll(c *fiber.Ctx) error {
userID := GetUserID(c)
res, err := r.notificationSvc.GetAll(userID)
if err != nil {
return err
}
return c.JSON(res)
}