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:
nepiedg
2025-12-31 03:18:03 +00:00
parent 2884f54666
commit cd7ae5ac56
14 changed files with 320 additions and 9 deletions
+11 -6
View File
@@ -6,14 +6,16 @@ import (
"github.com/gin-gonic/gin"
"wx_service/config"
authhandler "wx_service/internal/common/auth/handler"
authservice "wx_service/internal/common/auth/service"
commonhandler "wx_service/internal/common/handler"
commonservice "wx_service/internal/common/service"
"wx_service/internal/database"
"wx_service/internal/handler"
"wx_service/internal/model"
rmhandler "wx_service/internal/remove_watermark/handler"
rmmodel "wx_service/internal/remove_watermark/model"
rmservice "wx_service/internal/remove_watermark/service"
"wx_service/internal/routes"
"wx_service/internal/service"
smokehandler "wx_service/internal/smoke/handler"
smokemodel "wx_service/internal/smoke/model"
smokeservice "wx_service/internal/smoke/service"
@@ -43,9 +45,9 @@ func main() {
router := gin.Default()
// 5) 依赖注入:先创建 service,再创建 handlerhandler 只关心 HTTP 输入/输出)
miniProgramService := service.NewMiniProgramService(database.DB)
authService := service.NewAuthService(database.DB, miniProgramService)
authHandler := handler.NewAuthHandler(authService)
miniProgramService := authservice.NewMiniProgramService(database.DB)
authService := authservice.NewAuthService(database.DB, miniProgramService)
authHandler := authhandler.NewAuthHandler(authService)
videoService, err := rmservice.NewVideoService(database.DB, config.AppConfig.ShortVideo)
if err != nil {
log.Fatalf("init video service failed: %v", err)
@@ -55,8 +57,11 @@ func main() {
smokeLogService := smokeservice.NewSmokeLogService(database.DB)
smokeHandler := smokehandler.NewSmokeHandler(smokeLogService)
qiniuService := commonservice.NewQiniuService(config.AppConfig.Qiniu)
uploadHandler := commonhandler.NewUploadHandler(qiniuService)
// 6) 注册路由:把 URL 映射到 handler
routes.Register(router, database.DB, authHandler, videoHandler, smokeHandler)
routes.Register(router, database.DB, authHandler, videoHandler, smokeHandler, uploadHandler)
// 7) 启动监听端口
addr := ":" + config.AppConfig.Server.Port