package education import ( "veza-backend-api/internal/middleware" "github.com/gin-gonic/gin" ) // SetupRoutes configure les routes d'éducation func SetupRoutes(router *gin.RouterGroup, handler *Handler, jwtSecret string, authMiddleware *middleware.AuthMiddleware) { // Added authMiddleware parameter // Groupe de routes pour l'éducation edu := router.Group("/education") { // Routes des cours courses := edu.Group("/courses") courses.Use(authMiddleware.RequireAuth()) // Changed to authMiddleware.RequireAuth() { courses.POST("/create", handler.CreateCourse) courses.GET("/list", handler.ListCourses) courses.GET("/:course_id", handler.GetCourse) courses.PUT("/:course_id", handler.UpdateCourse) courses.DELETE("/:course_id", handler.DeleteCourse) courses.POST("/:course_id/lessons", handler.AddLesson) courses.POST("/:course_id/lessons/:lesson_id/exercises", handler.AddExercise) courses.GET("/:course_id/progress", handler.GetUserProgress) courses.PUT("/:course_id/progress", handler.UpdateUserProgress) courses.POST("/:course_id/certificate", handler.IssueCertificate) } // Routes des tutoriels tutorials := edu.Group("/tutorials") { // Routes publiques (sans authentification) tutorials.GET("/list", handler.ListTutorials) tutorials.GET("/search", handler.SearchTutorials) tutorials.GET("/:tutorial_id", handler.GetTutorial) tutorials.GET("/:tutorial_id/steps", handler.GetTutorialSteps) tutorials.GET("/:tutorial_id/comments", handler.GetTutorialComments) tutorials.POST("/:tutorial_id/like", handler.LikeTutorial) tutorials.POST("/:tutorial_id/dislike", handler.DislikeTutorial) // Routes protégées (avec authentification) protected := tutorials.Group("") protected.Use(authMiddleware.RequireAuth()) // Changed to authMiddleware.RequireAuth() { protected.POST("/create", handler.CreateTutorial) protected.PUT("/:tutorial_id", handler.UpdateTutorial) protected.DELETE("/:tutorial_id", handler.DeleteTutorial) protected.POST("/:tutorial_id/steps", handler.AddTutorialStep) protected.POST("/:tutorial_id/comments", handler.AddTutorialComment) } } } }