Add short video configuration and related API endpoints
- Updated .env.example to include SHORT_VIDEO_API_KEY, SHORT_VIDEO_FREE_QUOTA, and SHORT_VIDEO_TIMEOUT_SECONDS. - Enhanced main.go to auto-migrate new VideoParseLog and VideoParseUnlock models. - Introduced VideoService and VideoHandler for handling video-related operations. - Added protected API routes for removing watermarks and unlocking video features. - Updated config.go to support short video configuration settings. - Expanded documentation to reflect new features and configuration options.
This commit is contained in:
+13
-1
@@ -9,6 +9,7 @@ import (
|
||||
"wx_service/config"
|
||||
"wx_service/internal/database"
|
||||
"wx_service/internal/handler"
|
||||
"wx_service/internal/middleware"
|
||||
"wx_service/internal/model"
|
||||
"wx_service/internal/service"
|
||||
)
|
||||
@@ -19,7 +20,7 @@ func main() {
|
||||
if err := database.InitDB(); err != nil {
|
||||
log.Fatalf("init database failed: %v", err)
|
||||
}
|
||||
if err := database.AutoMigrate(&model.MiniProgram{}, &model.User{}); err != nil {
|
||||
if err := database.AutoMigrate(&model.MiniProgram{}, &model.User{}, &model.VideoParseLog{}, &model.VideoParseUnlock{}); err != nil {
|
||||
log.Fatalf("auto migrate failed: %v", err)
|
||||
}
|
||||
|
||||
@@ -29,10 +30,21 @@ func main() {
|
||||
miniProgramService := service.NewMiniProgramService(database.DB)
|
||||
authService := service.NewAuthService(database.DB, miniProgramService)
|
||||
authHandler := handler.NewAuthHandler(authService)
|
||||
videoService, err := service.NewVideoService(database.DB, config.AppConfig.ShortVideo)
|
||||
if err != nil {
|
||||
log.Fatalf("init video service failed: %v", err)
|
||||
}
|
||||
videoHandler := handler.NewVideoHandler(videoService)
|
||||
|
||||
api := router.Group("/api/v1")
|
||||
{
|
||||
api.POST("/auth/login", authHandler.LoginWithWeChat)
|
||||
protected := api.Group("")
|
||||
protected.Use(middleware.AuthMiddleware(database.DB))
|
||||
{
|
||||
protected.POST("/video/remove_watermark", videoHandler.RemoveWatermark)
|
||||
protected.POST("/video/remove_watermark/unlock", videoHandler.UnlockQuota)
|
||||
}
|
||||
}
|
||||
|
||||
router.GET("/healthz", func(c *gin.Context) {
|
||||
|
||||
Reference in New Issue
Block a user