package admin import ( "dd_fiber_api/internal/admin/statistics" admin_auth_handler "dd_fiber_api/internal/admin_auth/handler" admin_auth_middleware "dd_fiber_api/internal/admin_auth/middleware" admin_auth_service "dd_fiber_api/internal/admin_auth/service" camp_handler "dd_fiber_api/internal/camp/handler" document_handler "dd_fiber_api/internal/document/handler" order_handler "dd_fiber_api/internal/order/handler" "dd_fiber_api/internal/oss" "dd_fiber_api/internal/payment" question_handler "dd_fiber_api/internal/question/handler" "dd_fiber_api/internal/scheduler" "github.com/gofiber/fiber/v2" ) // SetupRoutes 设置Admin路由(管理端) func SetupRoutes(app *fiber.App, ossHandler *oss.Handler, paymentHandler *payment.Handler, schedulerHandler *scheduler.Handler, campCategoryHandler *camp_handler.CategoryHandler, campHandler *camp_handler.CampHandler, sectionHandler *camp_handler.SectionHandler, taskHandler *camp_handler.TaskHandler, progressHandler *camp_handler.ProgressHandler, userCampHandler *camp_handler.UserCampHandler, orderHandler *order_handler.OrderHandler, questionHandler *question_handler.QuestionHandler, paperHandler *question_handler.PaperHandler, answerRecordHandler *question_handler.AnswerRecordHandler, materialHandler *question_handler.MaterialHandler, knowledgeTreeHandler *question_handler.KnowledgeTreeHandler, documentHandler *document_handler.Handler, authHandler *admin_auth_handler.AuthHandler, authService *admin_auth_service.AuthService, statisticsHandler *statistics.Handler, adminUserHandler *admin_auth_handler.AdminUserHandler, roleHandler *admin_auth_handler.RoleHandler, permissionHandler *admin_auth_handler.PermissionHandler) { // 健康检查 app.Get("/health", func(c *fiber.Ctx) error { return c.JSON(fiber.Map{ "status": "ok", "service": "admin", }) }).Name("health.check") // API版本前缀 v1 := app.Group("/admin/v1") // 认证相关路由(不需要认证) if authHandler != nil { auth := v1.Group("/auth") auth.Post("/login", authHandler.Login).Name("管理员登录") auth.Post("/logout", authHandler.Logout).Name("管理员登出") } // 需要认证的路由 authenticated := v1.Group("", admin_auth_middleware.AuthMiddleware(authService)) // 获取当前用户信息 if authHandler != nil { authenticated.Get("/auth/me", admin_auth_middleware.PermissionMiddleware("admin:auth:me:read"), authHandler.GetMe).Name("获取当前用户信息") } // 各模块路由设置(需要认证) SetupOSSRoutes(authenticated, ossHandler) SetupPaymentRoutes(authenticated, paymentHandler) SetupSchedulerRoutes(authenticated, schedulerHandler) SetupCampRoutes(authenticated, campCategoryHandler, campHandler, sectionHandler, taskHandler, progressHandler, userCampHandler) SetupOrderRoutes(authenticated, orderHandler) SetupQuestionRoutes(authenticated, questionHandler, paperHandler, answerRecordHandler, materialHandler, knowledgeTreeHandler) SetupStatisticsRoutes(authenticated, statisticsHandler) SetupAdminUserRoutes(authenticated, adminUserHandler) SetupRoleRoutes(authenticated, roleHandler) SetupPermissionRoutes(authenticated, permissionHandler) SetupDocumentRoutes(authenticated, documentHandler) }