2025-12-10 18:33:37 +08:00
|
|
|
package api
|
|
|
|
|
|
|
|
|
|
import (
|
2026-01-27 22:20:07 +08:00
|
|
|
"gitea.com/texpixel/document_ai/api/v1/analytics"
|
2026-01-27 21:56:21 +08:00
|
|
|
"gitea.com/texpixel/document_ai/api/v1/formula"
|
|
|
|
|
"gitea.com/texpixel/document_ai/api/v1/oss"
|
|
|
|
|
"gitea.com/texpixel/document_ai/api/v1/task"
|
|
|
|
|
"gitea.com/texpixel/document_ai/api/v1/user"
|
|
|
|
|
"gitea.com/texpixel/document_ai/pkg/common"
|
2025-12-10 18:33:37 +08:00
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func SetupRouter(engine *gin.RouterGroup) {
|
|
|
|
|
v1 := engine.Group("/v1")
|
|
|
|
|
{
|
2025-12-18 15:14:42 +08:00
|
|
|
formulaRouter := v1.Group("/formula", common.GetAuthMiddleware())
|
|
|
|
|
{
|
|
|
|
|
endpoint := formula.NewFormulaEndpoint()
|
|
|
|
|
formulaRouter.POST("/recognition", endpoint.CreateTask)
|
|
|
|
|
formulaRouter.POST("/ai_enhance", endpoint.AIEnhanceRecognition)
|
|
|
|
|
formulaRouter.GET("/recognition/:task_no", endpoint.GetTaskStatus)
|
2025-12-20 22:48:02 +08:00
|
|
|
formulaRouter.POST("/test_process_mathpix_task", endpoint.TestProcessMathpixTask)
|
2025-12-18 15:14:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
taskRouter := v1.Group("/task", common.GetAuthMiddleware())
|
|
|
|
|
{
|
|
|
|
|
endpoint := task.NewTaskEndpoint()
|
|
|
|
|
taskRouter.POST("/evaluate", endpoint.EvaluateTask)
|
2025-12-19 13:59:47 +08:00
|
|
|
taskRouter.GET("/list", common.MustAuthMiddleware(), endpoint.GetTaskList)
|
2025-12-26 16:24:34 +08:00
|
|
|
taskRouter.POST("/export", endpoint.ExportTask)
|
2025-12-18 15:14:42 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ossRouter := v1.Group("/oss", common.GetAuthMiddleware())
|
|
|
|
|
{
|
|
|
|
|
endpoint := oss.NewOSSEndpoint()
|
|
|
|
|
ossRouter.POST("/signature", endpoint.GetPostObjectSignature)
|
|
|
|
|
ossRouter.POST("/signature_url", endpoint.GetSignatureURL)
|
|
|
|
|
ossRouter.POST("/file/upload", endpoint.UploadFile)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
userRouter := v1.Group("/user", common.GetAuthMiddleware())
|
|
|
|
|
{
|
|
|
|
|
userEndpoint := user.NewUserEndpoint()
|
|
|
|
|
{
|
|
|
|
|
userRouter.POST("/sms", userEndpoint.SendVerificationCode)
|
|
|
|
|
userRouter.POST("/register", userEndpoint.RegisterByEmail)
|
|
|
|
|
userRouter.POST("/login", userEndpoint.LoginByEmail)
|
|
|
|
|
userRouter.GET("/info", common.MustAuthMiddleware(), userEndpoint.GetUserInfo)
|
|
|
|
|
}
|
|
|
|
|
}
|
2026-01-27 22:20:07 +08:00
|
|
|
|
|
|
|
|
// 数据埋点路由
|
|
|
|
|
analyticsRouter := v1.Group("/analytics", common.GetAuthMiddleware())
|
|
|
|
|
{
|
|
|
|
|
analyticsHandler := analytics.NewAnalyticsHandler()
|
|
|
|
|
analyticsRouter.POST("/track", analyticsHandler.TrackEvent)
|
|
|
|
|
}
|
2025-12-10 18:33:37 +08:00
|
|
|
}
|
2025-12-18 15:14:42 +08:00
|
|
|
|
2025-12-10 18:33:37 +08:00
|
|
|
}
|