feat: add file upload workflow
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"hfb_sys/backend/internal/modules/adminuser"
|
||||
"hfb_sys/backend/internal/modules/auth"
|
||||
"hfb_sys/backend/internal/modules/dispute"
|
||||
filemodule "hfb_sys/backend/internal/modules/file"
|
||||
"hfb_sys/backend/internal/modules/listing"
|
||||
"hfb_sys/backend/internal/modules/notification"
|
||||
"hfb_sys/backend/internal/modules/order"
|
||||
@@ -108,6 +109,16 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
}
|
||||
systemConfigService := systemconfig.NewService(systemConfigRepo)
|
||||
systemConfigHandler := systemconfig.NewHandler(systemConfigService)
|
||||
var fileStorage *filemodule.Storage
|
||||
if cfg.Storage.Endpoint != "" && cfg.Storage.Bucket != "" {
|
||||
var err error
|
||||
fileStorage, err = filemodule.NewStorage(cfg.Storage)
|
||||
if err != nil {
|
||||
logger.Warn("file storage unavailable; file APIs will return 503", zap.Error(err))
|
||||
}
|
||||
}
|
||||
fileService := filemodule.NewService(fileStorage)
|
||||
fileHandler := filemodule.NewHandler(fileService, fileStorage)
|
||||
requireAuth := middleware.Auth(jwtManager)
|
||||
requireAdmin := middleware.AdminAuth(jwtManager)
|
||||
requireRealname := middleware.RequireRealname(userRepo)
|
||||
@@ -168,6 +179,12 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
walletRoutes.GET("/ledger", walletHandler.Ledger)
|
||||
}
|
||||
|
||||
fileRoutes := api.Group("/files", requireAuth)
|
||||
{
|
||||
fileRoutes.POST("/upload", fileHandler.Upload)
|
||||
fileRoutes.GET("/object", fileHandler.Object)
|
||||
}
|
||||
|
||||
notificationRoutes := api.Group("/notifications", requireAuth)
|
||||
{
|
||||
notificationRoutes.GET("", notificationHandler.List)
|
||||
@@ -191,6 +208,7 @@ func New(cfg config.Config, deps Dependencies, logger *zap.Logger) *gin.Engine {
|
||||
adminRoutes.GET("/me", adminAuthHandler.Me)
|
||||
adminRoutes.POST("/auth/logout", adminAuthHandler.Logout)
|
||||
adminRoutes.GET("/dashboard", adminDashboardHandler.Summary)
|
||||
adminRoutes.GET("/files/object", fileHandler.Object)
|
||||
adminRoutes.GET("/users", adminUserHandler.List)
|
||||
adminRoutes.POST("/users/:id/freeze", adminUserHandler.Freeze)
|
||||
adminRoutes.POST("/users/:id/unfreeze", adminUserHandler.Unfreeze)
|
||||
|
||||
Reference in New Issue
Block a user