初始化2
This commit is contained in:
@@ -46,6 +46,7 @@ func SetupRouter() *gin.Engine {
|
||||
chunkCtrl := controller.NewChunkUploadController()
|
||||
monitorCtrl := controller.NewMonitorController()
|
||||
openCtrl := controller.NewOpenAPIController()
|
||||
openFileCtrl := controller.NewOpenAPIFileController()
|
||||
|
||||
// API路由组
|
||||
api := r.Group("/api")
|
||||
@@ -54,6 +55,7 @@ func SetupRouter() *gin.Engine {
|
||||
auth := api.Group("/auth")
|
||||
{
|
||||
auth.POST("/login", authCtrl.Login)
|
||||
auth.POST("/app-login", authCtrl.AppLogin)
|
||||
auth.POST("/register", authCtrl.Register)
|
||||
}
|
||||
|
||||
@@ -71,6 +73,23 @@ func SetupRouter() *gin.Engine {
|
||||
{
|
||||
openapi.POST("/token/validate", openCtrl.ValidateToken)
|
||||
openapi.POST("/token/generate", openCtrl.GenerateTestToken)
|
||||
|
||||
// 文件操作API (需要JWT认证)
|
||||
openapi.Use(middleware.JWTAuth(cfg.JWT.Secret))
|
||||
{
|
||||
// 分页查询文件夹内容
|
||||
openapi.GET("/files", openFileCtrl.ListByFolder)
|
||||
// 按名称搜索
|
||||
openapi.GET("/files/search", openFileCtrl.SearchTree)
|
||||
// 下载/预览
|
||||
openapi.GET("/files/:id/download", openFileCtrl.Download)
|
||||
openapi.GET("/files/:id/preview", openFileCtrl.Preview)
|
||||
// 分片上传
|
||||
openapi.POST("/files/upload/init", openFileCtrl.ChunkUploadInit)
|
||||
openapi.PUT("/files/upload/chunk/:uploadId/:index", openFileCtrl.ChunkUpload)
|
||||
openapi.POST("/files/upload/merge/:uploadId", openFileCtrl.ChunkMerge)
|
||||
openapi.GET("/files/upload/progress/:uploadId", openFileCtrl.ChunkProgress)
|
||||
}
|
||||
}
|
||||
|
||||
// ============ 需要登录的路由 ============
|
||||
@@ -91,6 +110,7 @@ func SetupRouter() *gin.Engine {
|
||||
// 分片上传
|
||||
file.POST("/upload/init", middleware.RequirePermission("file:upload"), chunkCtrl.Init)
|
||||
file.PUT("/upload/chunk/:uploadId/:index", middleware.RequirePermission("file:upload"), chunkCtrl.UploadChunk)
|
||||
file.POST("/upload/chunk/:uploadId/:index/confirm", middleware.RequirePermission("file:upload"), chunkCtrl.ConfirmChunk)
|
||||
file.POST("/upload/merge/:uploadId", middleware.RequirePermission("file:upload"), chunkCtrl.Merge)
|
||||
file.GET("/upload/progress/:uploadId", chunkCtrl.Progress)
|
||||
file.DELETE("/upload/:uploadId", chunkCtrl.Cancel)
|
||||
@@ -109,12 +129,18 @@ func SetupRouter() *gin.Engine {
|
||||
file.DELETE("/:id", middleware.RequirePermission("file:delete"), fileCtrl.SoftDelete)
|
||||
file.POST("/:id/restore", fileCtrl.Restore)
|
||||
file.DELETE("/:id/permanent", middleware.RequirePermission("file:delete"), fileCtrl.HardDelete)
|
||||
|
||||
// 文件权限管理
|
||||
file.GET("/:id/grant", fileCtrl.ListPermissions)
|
||||
file.POST("/:id/grant", middleware.RequirePermission("file:grant"), fileCtrl.GrantPermission)
|
||||
file.DELETE("/:id/grant/:permId", middleware.RequirePermission("file:grant"), fileCtrl.RevokePermission)
|
||||
}
|
||||
|
||||
// 文件夹管理
|
||||
folder := protected.Group("/folder")
|
||||
{
|
||||
folder.POST("", middleware.RequirePermission("file:create"), folderCtrl.Create)
|
||||
folder.GET("/by-bizid/:bizid", folderCtrl.GetByBizID)
|
||||
folder.GET("/:id/children", folderCtrl.ListChildren)
|
||||
folder.GET("/root", func(c *gin.Context) {
|
||||
c.Params = append(c.Params, gin.Param{Key: "id", Value: "root"})
|
||||
@@ -196,6 +222,7 @@ func SetupRouter() *gin.Engine {
|
||||
admin.GET("/monitor/traffic", monitorCtrl.GetTrafficStats)
|
||||
admin.GET("/monitor/requests", monitorCtrl.GetRecentRequests)
|
||||
admin.GET("/monitor/storage", monitorCtrl.GetStorageStats)
|
||||
admin.GET("/monitor/logs", monitorCtrl.GetSystemLogs)
|
||||
|
||||
// IP黑名单
|
||||
admin.GET("/blacklist", monitorCtrl.GetBlacklist)
|
||||
|
||||
Reference in New Issue
Block a user