mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-08 00:26:37 +08:00
feat(storage): implement user-group level file management dashboard and APIs
- Expose user-scoped CRUD APIs under `/api/v1/upload` (my files query, stats, rename, delete) - Update backend handlers and routers with ownership validation checks - Create a dedicated frontend personal file manager card-list and upload button under `/files` - Add comprehensive backend test coverage and update API docs
This commit is contained in:
+27
-14
@@ -210,11 +210,7 @@ func registerRoutes(r *gin.Engine) {
|
||||
}
|
||||
|
||||
// Upload
|
||||
uploadRouter := apiV1Router.Group("/upload")
|
||||
uploadRouter.Use(oauth.LoginRequired())
|
||||
{
|
||||
uploadRouter.POST("", upload.UploadFile)
|
||||
}
|
||||
registerUploadRoutes(apiV1Router)
|
||||
|
||||
// Config (public)
|
||||
configRouter := apiV1Router.Group("/config")
|
||||
@@ -277,15 +273,7 @@ func registerRoutes(r *gin.Engine) {
|
||||
adminRouter.DELETE("/users/:id", admin_user.DeleteUser)
|
||||
|
||||
// Uploads
|
||||
adminUploadsRouter := adminRouter.Group("/uploads")
|
||||
{
|
||||
adminUploadsRouter.GET("", upload.ListFiles)
|
||||
adminUploadsRouter.GET("/stats", upload.GetFileStats)
|
||||
adminUploadsRouter.DELETE("/:id", upload.DeleteFile)
|
||||
adminUploadsRouter.GET("/download/:id", upload.DownloadFile)
|
||||
adminUploadsRouter.POST("/download/batch", upload.BatchDownloadFiles)
|
||||
adminUploadsRouter.GET("/types", upload.GetDistinctUploadTypes)
|
||||
}
|
||||
registerAdminUploadRoutes(adminRouter)
|
||||
|
||||
// System Config
|
||||
adminRouter.POST("/system-configs", system_config.CreateSystemConfig)
|
||||
@@ -325,3 +313,28 @@ func registerRoutes(r *gin.Engine) {
|
||||
// 注册前端静态路由(当启用 embed_frontend 编译标签时)
|
||||
registerFrontend(r)
|
||||
}
|
||||
|
||||
func registerUploadRoutes(apiV1Router *gin.RouterGroup) {
|
||||
uploadRouter := apiV1Router.Group("/upload")
|
||||
uploadRouter.Use(oauth.LoginRequired())
|
||||
{
|
||||
uploadRouter.POST("", upload.UploadFile)
|
||||
uploadRouter.GET("/my", upload.ListMyFiles)
|
||||
uploadRouter.DELETE("/:id", upload.DeleteMyFile)
|
||||
uploadRouter.PUT("/:id", upload.UpdateMyFile)
|
||||
uploadRouter.GET("/download/:id", upload.DownloadFile)
|
||||
uploadRouter.POST("/download/batch", upload.BatchDownloadFiles)
|
||||
}
|
||||
}
|
||||
|
||||
func registerAdminUploadRoutes(adminRouter *gin.RouterGroup) {
|
||||
adminUploadsRouter := adminRouter.Group("/uploads")
|
||||
{
|
||||
adminUploadsRouter.GET("", upload.ListFiles)
|
||||
adminUploadsRouter.GET("/stats", upload.GetFileStats)
|
||||
adminUploadsRouter.DELETE("/:id", upload.DeleteFile)
|
||||
adminUploadsRouter.GET("/download/:id", upload.DownloadFile)
|
||||
adminUploadsRouter.POST("/download/batch", upload.BatchDownloadFiles)
|
||||
adminUploadsRouter.GET("/types", upload.GetDistinctUploadTypes)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user