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:
+26
-3
@@ -3,14 +3,17 @@ package config
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Server ServerConfig
|
||||
Database DatabaseConfig
|
||||
JWT JWTConfig
|
||||
Server ServerConfig
|
||||
Database DatabaseConfig
|
||||
JWT JWTConfig
|
||||
ShortVideo ShortVideoConfig
|
||||
}
|
||||
|
||||
type ServerConfig struct {
|
||||
@@ -31,6 +34,12 @@ type JWTConfig struct {
|
||||
Expire int
|
||||
}
|
||||
|
||||
type ShortVideoConfig struct {
|
||||
APIKey string
|
||||
FreeDailyQuota int
|
||||
RequestTimeout time.Duration
|
||||
}
|
||||
|
||||
var AppConfig *Config
|
||||
|
||||
func LoadConfig() {
|
||||
@@ -55,6 +64,11 @@ func LoadConfig() {
|
||||
Secret: getEnv("JWT_SECRET", "your-secret-key"),
|
||||
Expire: 86400, // 24小时
|
||||
},
|
||||
ShortVideo: ShortVideoConfig{
|
||||
APIKey: getEnv("SHORT_VIDEO_API_KEY", ""),
|
||||
FreeDailyQuota: getEnvAsInt("SHORT_VIDEO_FREE_QUOTA", 20),
|
||||
RequestTimeout: time.Duration(getEnvAsInt("SHORT_VIDEO_TIMEOUT_SECONDS", 5)) * time.Second,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,3 +78,12 @@ func getEnv(key, defaultValue string) string {
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
func getEnvAsInt(key string, defaultValue int) int {
|
||||
if value := os.Getenv(key); value != "" {
|
||||
if v, err := strconv.Atoi(value); err == nil {
|
||||
return v
|
||||
}
|
||||
}
|
||||
return defaultValue
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user