40 lines
1.7 KiB
Go
40 lines
1.7 KiB
Go
package api
|
||
|
||
import (
|
||
camp_handler "dd_fiber_api/internal/camp/handler"
|
||
order_handler "dd_fiber_api/internal/order/handler"
|
||
question_handler "dd_fiber_api/internal/question/handler"
|
||
"dd_fiber_api/internal/oss"
|
||
"dd_fiber_api/internal/payment"
|
||
"dd_fiber_api/internal/scheduler"
|
||
|
||
"github.com/gofiber/fiber/v2"
|
||
)
|
||
|
||
// SetupRoutes 设置API路由(微信小程序接口)
|
||
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) {
|
||
// 健康检查
|
||
app.Get("/health", func(c *fiber.Ctx) error {
|
||
return c.JSON(fiber.Map{
|
||
"status": "ok",
|
||
"service": "api",
|
||
})
|
||
}).Name("health.check")
|
||
|
||
// API版本前缀
|
||
v1 := app.Group("/api/v1")
|
||
|
||
// 订单路由(必须在其他路由之前注册,避免路由冲突)
|
||
SetupOrderRoutes(v1, orderHandler)
|
||
// oss路由
|
||
SetupOSSRoutes(v1, ossHandler)
|
||
// 支付路由
|
||
SetupPaymentRoutes(v1, paymentHandler)
|
||
// 调度器路由 定时任务 调度器
|
||
SetupSchedulerRoutes(v1, schedulerHandler)
|
||
// 打卡营路由
|
||
SetupCampRoutes(v1, campCategoryHandler, campHandler, sectionHandler, taskHandler, progressHandler, userCampHandler)
|
||
// 题目相关路由
|
||
SetupQuestionRoutes(app, questionHandler, paperHandler, answerRecordHandler)
|
||
}
|