From 0fba1901c8d5a494e9501c4e96a17dfc537b6bdf Mon Sep 17 00:00:00 2001 From: PMExtra Date: Mon, 2 Mar 2026 10:54:14 +0800 Subject: [PATCH] fix(ci): fix backend unit test constructor arg and gofmt issues --- .../internal/handler/admin/setting_handler.go | 4 +-- backend/internal/handler/dto/settings.go | 4 +-- backend/internal/service/auth_service.go | 36 +++++++++---------- .../auth_service_turnstile_register_test.go | 1 + backend/internal/service/domain_constants.go | 6 ++-- backend/internal/service/settings_view.go | 4 +-- 6 files changed, 28 insertions(+), 27 deletions(-) diff --git a/backend/internal/handler/admin/setting_handler.go b/backend/internal/handler/admin/setting_handler.go index 3cc1388a..e7da042c 100644 --- a/backend/internal/handler/admin/setting_handler.go +++ b/backend/internal/handler/admin/setting_handler.go @@ -154,8 +154,8 @@ type UpdateSettingsRequest struct { SoraClientEnabled bool `json:"sora_client_enabled"` // 默认配置 - DefaultConcurrency int `json:"default_concurrency"` - DefaultBalance float64 `json:"default_balance"` + DefaultConcurrency int `json:"default_concurrency"` + DefaultBalance float64 `json:"default_balance"` DefaultSubscriptions []dto.DefaultSubscriptionSetting `json:"default_subscriptions"` // Model fallback configuration diff --git a/backend/internal/handler/dto/settings.go b/backend/internal/handler/dto/settings.go index 6a8c423d..e9086010 100644 --- a/backend/internal/handler/dto/settings.go +++ b/backend/internal/handler/dto/settings.go @@ -39,8 +39,8 @@ type SystemSettings struct { PurchaseSubscriptionURL string `json:"purchase_subscription_url"` SoraClientEnabled bool `json:"sora_client_enabled"` - DefaultConcurrency int `json:"default_concurrency"` - DefaultBalance float64 `json:"default_balance"` + DefaultConcurrency int `json:"default_concurrency"` + DefaultBalance float64 `json:"default_balance"` DefaultSubscriptions []DefaultSubscriptionSetting `json:"default_subscriptions"` // Model fallback configuration diff --git a/backend/internal/service/auth_service.go b/backend/internal/service/auth_service.go index 65684492..fe3a0f25 100644 --- a/backend/internal/service/auth_service.go +++ b/backend/internal/service/auth_service.go @@ -56,15 +56,15 @@ type JWTClaims struct { // AuthService 认证服务 type AuthService struct { - userRepo UserRepository - redeemRepo RedeemCodeRepository - refreshTokenCache RefreshTokenCache - cfg *config.Config - settingService *SettingService - emailService *EmailService - turnstileService *TurnstileService - emailQueueService *EmailQueueService - promoService *PromoService + userRepo UserRepository + redeemRepo RedeemCodeRepository + refreshTokenCache RefreshTokenCache + cfg *config.Config + settingService *SettingService + emailService *EmailService + turnstileService *TurnstileService + emailQueueService *EmailQueueService + promoService *PromoService defaultSubAssigner DefaultSubscriptionAssigner } @@ -86,15 +86,15 @@ func NewAuthService( defaultSubAssigner DefaultSubscriptionAssigner, ) *AuthService { return &AuthService{ - userRepo: userRepo, - redeemRepo: redeemRepo, - refreshTokenCache: refreshTokenCache, - cfg: cfg, - settingService: settingService, - emailService: emailService, - turnstileService: turnstileService, - emailQueueService: emailQueueService, - promoService: promoService, + userRepo: userRepo, + redeemRepo: redeemRepo, + refreshTokenCache: refreshTokenCache, + cfg: cfg, + settingService: settingService, + emailService: emailService, + turnstileService: turnstileService, + emailQueueService: emailQueueService, + promoService: promoService, defaultSubAssigner: defaultSubAssigner, } } diff --git a/backend/internal/service/auth_service_turnstile_register_test.go b/backend/internal/service/auth_service_turnstile_register_test.go index 7dd9edca..36cb1e06 100644 --- a/backend/internal/service/auth_service_turnstile_register_test.go +++ b/backend/internal/service/auth_service_turnstile_register_test.go @@ -52,6 +52,7 @@ func newAuthServiceForRegisterTurnstileTest(settings map[string]string, verifier turnstileService, nil, // emailQueueService nil, // promoService + nil, // defaultSubAssigner ) } diff --git a/backend/internal/service/domain_constants.go b/backend/internal/service/domain_constants.go index 8f49e049..b304bc9f 100644 --- a/backend/internal/service/domain_constants.go +++ b/backend/internal/service/domain_constants.go @@ -117,9 +117,9 @@ const ( SettingKeyPurchaseSubscriptionURL = "purchase_subscription_url" // “购买订阅”页面 URL(作为 iframe src) // 默认配置 - SettingKeyDefaultConcurrency = "default_concurrency" // 新用户默认并发量 - SettingKeyDefaultBalance = "default_balance" // 新用户默认余额 - SettingKeyDefaultSubscriptions = "default_subscriptions" // 新用户默认订阅列表(JSON) + SettingKeyDefaultConcurrency = "default_concurrency" // 新用户默认并发量 + SettingKeyDefaultBalance = "default_balance" // 新用户默认余额 + SettingKeyDefaultSubscriptions = "default_subscriptions" // 新用户默认订阅列表(JSON) // 管理员 API Key SettingKeyAdminAPIKey = "admin_api_key" // 全局管理员 API Key(用于外部系统集成) diff --git a/backend/internal/service/settings_view.go b/backend/internal/service/settings_view.go index 8c96e564..5a441ea1 100644 --- a/backend/internal/service/settings_view.go +++ b/backend/internal/service/settings_view.go @@ -41,8 +41,8 @@ type SystemSettings struct { PurchaseSubscriptionURL string SoraClientEnabled bool - DefaultConcurrency int - DefaultBalance float64 + DefaultConcurrency int + DefaultBalance float64 DefaultSubscriptions []DefaultSubscriptionSetting // Model fallback configuration