package router import ( "net/http" "speechAnalysis/conf" "speechAnalysis/controllers" _ "speechAnalysis/docs" "speechAnalysis/middleware" "github.com/gin-gonic/gin" swaggerFiles "github.com/swaggo/files" ginSwagger "github.com/swaggo/gin-swagger" ) func NewRouter() *gin.Engine { r := gin.Default() r.Use(middleware.Cors()) r.StaticFS(conf.LocalConf.StorePath, http.Dir(conf.LocalConf.StorePath)) // 为用户头像和文件提供静态地址 r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler)) urlPrefix := "/api-sa/v1" // 音频管理 AudioCtl := new(controllers.AudioCtl) organizeAPI := r.Group(urlPrefix + "/audio") { organizeAPI.POST("upload", AudioCtl.Upload) // 上传音频 organizeAPI.GET("list", AudioCtl.List) // 音频检索 organizeAPI.POST("process", AudioCtl.Process) // 音频处理 organizeAPI.POST("batchProcess", AudioCtl.BatchProcess) // 音频批量处理 organizeAPI.POST("delete", AudioCtl.Delete) // 音频删除 organizeAPI.POST("batchDelete", AudioCtl.BatchDelete) // 音频批量删除 organizeAPI.POST("follow", AudioCtl.Follow) // 关注/取消关注 } return r }