package interfaces import ( "mengstack/internal/app/middleware" "mengstack/internal/modules/notification/application" "mengstack/internal/modules/notification/infrastructure" "github.com/gin-gonic/gin" "go.uber.org/fx" "go.uber.org/zap" "gorm.io/gorm" ) func SetupRoutes( r *gin.Engine, h *Handler, authMW gin.HandlerFunc, ) { notifications := r.Group("/api/v1/notifications") notifications.Use(authMW, middleware.MultiTenant()) { notifications.POST("", h.Create) notifications.GET("/:id", h.Get) notifications.DELETE("/:id", h.Delete) notifications.PUT("/:id/read", h.MarkAsRead) notifications.PUT("/read-all", h.MarkAllAsRead) notifications.GET("/unread-count", h.CountUnread) notifications.GET("/user/:userId", h.ListByUser) } } var Module = fx.Module("notification", fx.Provide( infrastructure.NewNotificationRepository, application.NewService, NewHandler, ), fx.Invoke(func(db *gorm.DB, log *zap.Logger) { if err := infrastructure.Migrate(db); err != nil { log.Fatal("notification migration failed", zap.Error(err)) } }), )