package interfaces import ( "mengstack/internal/app/middleware" "mengstack/internal/modules/org/application" "mengstack/internal/modules/org/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) { org := r.Group("/api/v1/org") org.Use(authMW, middleware.MultiTenant()) { org.POST("/tenants", h.CreateTenant) org.GET("/tenants", h.ListTenants) org.GET("/tenants/:id", h.GetTenant) org.PUT("/tenants/:id", h.UpdateTenant) org.DELETE("/tenants/:id", h.DeleteTenant) } } var Module = fx.Module("org", fx.Provide( infrastructure.NewTenantRepository, application.NewService, NewHandler, ), fx.Invoke(func(db *gorm.DB, log *zap.Logger) { if err := infrastructure.Migrate(db); err != nil { log.Fatal("org migration failed", zap.Error(err)) } }), )