chore: import 分组规范 + 文档同步 + config 修复
All checks were successful
Build / build (push) Successful in 7m17s
Build / build-docker (push) Successful in 2m41s

This commit is contained in:
lafay
2026-06-15 16:52:20 +08:00
parent 7d1c78f965
commit b23a169925
32 changed files with 143 additions and 90 deletions

View File

@@ -259,6 +259,7 @@ func setupEnvMappings() {
viper.BindEnv("server.read_timeout", "SERVER_READ_TIMEOUT")
viper.BindEnv("server.write_timeout", "SERVER_WRITE_TIMEOUT")
viper.BindEnv("server.swagger_enabled", "SERVER_SWAGGER_ENABLED")
viper.BindEnv("environment", "ENVIRONMENT")
// 数据库配置
viper.BindEnv("database.driver", "DATABASE_DRIVER")
@@ -306,6 +307,10 @@ func setupEnvMappings() {
viper.BindEnv("log.level", "LOG_LEVEL")
viper.BindEnv("log.format", "LOG_FORMAT")
viper.BindEnv("log.output", "LOG_OUTPUT")
viper.BindEnv("log.max_size", "LOG_MAX_SIZE")
viper.BindEnv("log.max_backups", "LOG_MAX_BACKUPS")
viper.BindEnv("log.max_age", "LOG_MAX_AGE")
viper.BindEnv("log.compress", "LOG_COMPRESS")
// 邮件配置
viper.BindEnv("email.enabled", "EMAIL_ENABLED")
@@ -457,10 +462,7 @@ func overrideFromEnv(config *Config) {
config.Email.Enabled = emailEnabled == "true" || emailEnabled == "True" || emailEnabled == "TRUE" || emailEnabled == "1"
}
// 处理环境配置
if env := os.Getenv("ENVIRONMENT"); env != "" {
config.Environment = env
}
// 处理环境配置(已由 BindEnv("environment", "ENVIRONMENT") + AutomaticEnv 处理)
// 处理安全配置
if allowedOrigins := os.Getenv("SECURITY_ALLOWED_ORIGINS"); allowedOrigins != "" {

View File

@@ -1,9 +1,10 @@
package database
import (
"carrotskin/internal/model"
"fmt"
"carrotskin/internal/model"
"go.uber.org/zap"
"gorm.io/gorm"
)

View File

@@ -3,9 +3,9 @@ package logger
import (
"os"
"path/filepath"
"carrotskin/pkg/config"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
@@ -50,7 +50,7 @@ func New(cfg config.LogConfig) (*zap.Logger, error) {
if err := os.MkdirAll(logDir, 0755); err != nil {
return nil, err
}
file, err := os.OpenFile(cfg.Output, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err != nil {
return nil, err

View File

@@ -79,7 +79,6 @@ func (s *StorageClient) GetBucket(name string) (string, error) {
return bucket, nil
}
// BuildFileURL 构建文件的公开访问URL
func (s *StorageClient) BuildFileURL(bucketName, objectName string) string {
return fmt.Sprintf("%s/%s/%s", s.publicURL, bucketName, objectName)