Integrate Qiniu upload service and update configuration
- Added Qiniu configuration options to .env.example and config.go for file uploads. - Refactored main.go to include new Qiniu service and upload handler. - Updated route registration to accommodate the new upload handler. - Enhanced documentation to include references for Qiniu upload functionality. - Removed legacy authentication handler and services to streamline the codebase.
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package routes
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
|
||||
commonhandler "wx_service/internal/common/handler"
|
||||
)
|
||||
|
||||
func registerCommonRoutes(protected *gin.RouterGroup, uploadHandler *commonhandler.UploadHandler) {
|
||||
// 公共接口(所有小程序共用)
|
||||
common := protected.Group("/common")
|
||||
{
|
||||
// 七牛直传凭证:前端先拿 token,再直传文件到七牛 upload_url
|
||||
common.POST("/upload/qiniu/token", uploadHandler.QiniuToken)
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"wx_service/internal/handler"
|
||||
authhandler "wx_service/internal/common/auth/handler"
|
||||
commonhandler "wx_service/internal/common/handler"
|
||||
"wx_service/internal/middleware"
|
||||
rmhandler "wx_service/internal/remove_watermark/handler"
|
||||
smokehandler "wx_service/internal/smoke/handler"
|
||||
@@ -15,9 +16,10 @@ import (
|
||||
func Register(
|
||||
router *gin.Engine,
|
||||
db *gorm.DB,
|
||||
authHandler *handler.AuthHandler,
|
||||
authHandler *authhandler.AuthHandler,
|
||||
videoHandler *rmhandler.VideoHandler,
|
||||
smokeHandler *smokehandler.SmokeHandler,
|
||||
uploadHandler *commonhandler.UploadHandler,
|
||||
) {
|
||||
// Register 用来集中注册所有 HTTP 路由,便于工程结构更清晰:
|
||||
// - main 只负责初始化(配置/DB/依赖注入)
|
||||
@@ -31,6 +33,7 @@ func Register(
|
||||
protected := api.Group("")
|
||||
protected.Use(middleware.AuthMiddleware(db))
|
||||
{
|
||||
registerCommonRoutes(protected, uploadHandler)
|
||||
registerRemoveWatermarkRoutes(protected, videoHandler)
|
||||
registerSmokeRoutes(protected, smokeHandler)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user