diff --git a/backend/internal/handler/admin/account_handler.go b/backend/internal/handler/admin/account_handler.go index 3c8548346f..6bfdda793c 100644 --- a/backend/internal/handler/admin/account_handler.go +++ b/backend/internal/handler/admin/account_handler.go @@ -213,8 +213,8 @@ func (h *AccountHandler) buildAccountResponseWithRuntime(ctx context.Context, ac if clients, err := h.gatewayCache.GetAccountAffinityClientsBatch(ctx, accountGroups, service.ClientAffinityTTL); err == nil { if cl, ok := clients[account.ID]; ok { count := int64(len(cl)) - item.Account.AffinityClientCount = &count - item.Account.AffinityClients = cl + item.AffinityClientCount = &count + item.AffinityClients = cl } } } @@ -396,8 +396,8 @@ func (h *AccountHandler) List(c *gin.Context) { if affinityClients != nil { if clients, ok := affinityClients[acc.ID]; ok { count := int64(len(clients)) - item.Account.AffinityClientCount = &count - item.Account.AffinityClients = clients + item.AffinityClientCount = &count + item.AffinityClients = clients } } diff --git a/backend/internal/handler/dto/types.go b/backend/internal/handler/dto/types.go index 17a67d4ed1..303b9a43cb 100644 --- a/backend/internal/handler/dto/types.go +++ b/backend/internal/handler/dto/types.go @@ -193,14 +193,14 @@ type Account struct { ClientAffinityEnabled *bool `json:"client_affinity_enabled,omitempty"` // 亲和客户端数据(仅 admin 列表端点注入,不由 mapper 填充) - AffinityClientCount *int64 `json:"affinity_client_count,omitempty"` + AffinityClientCount *int64 `json:"affinity_client_count,omitempty"` AffinityClients []string `json:"affinity_clients,omitempty"` // API Key 账号配额限制 - QuotaLimit *float64 `json:"quota_limit,omitempty"` - QuotaUsed *float64 `json:"quota_used,omitempty"` - QuotaDailyLimit *float64 `json:"quota_daily_limit,omitempty"` - QuotaDailyUsed *float64 `json:"quota_daily_used,omitempty"` + QuotaLimit *float64 `json:"quota_limit,omitempty"` + QuotaUsed *float64 `json:"quota_used,omitempty"` + QuotaDailyLimit *float64 `json:"quota_daily_limit,omitempty"` + QuotaDailyUsed *float64 `json:"quota_daily_used,omitempty"` QuotaWeeklyLimit *float64 `json:"quota_weekly_limit,omitempty"` QuotaWeeklyUsed *float64 `json:"quota_weekly_used,omitempty"` diff --git a/backend/internal/service/settings_view.go b/backend/internal/service/settings_view.go index ceca3a828a..4c45f60173 100644 --- a/backend/internal/service/settings_view.go +++ b/backend/internal/service/settings_view.go @@ -140,7 +140,7 @@ type SoraS3Profile struct { UpdatedAt string `json:"updated_at"` // --- Google Drive 专属 --- - AuthType string `json:"auth_type,omitempty"` // "oauth2" / "service_account" + AuthType string `json:"auth_type,omitempty"` // "oauth2" / "service_account" ClientID string `json:"client_id,omitempty"` ClientSecret string `json:"-"` ClientSecretConfigured bool `json:"client_secret_configured"` diff --git a/backend/internal/service/sora_gdrive_oauth.go b/backend/internal/service/sora_gdrive_oauth.go index 5fce55c74b..61282053ca 100644 --- a/backend/internal/service/sora_gdrive_oauth.go +++ b/backend/internal/service/sora_gdrive_oauth.go @@ -12,15 +12,11 @@ import ( ) // SoraGDriveOAuthService 处理 Google Drive OAuth2 授权流程。 -type SoraGDriveOAuthService struct { - settingService *SettingService -} +type SoraGDriveOAuthService struct{} // NewSoraGDriveOAuthService 创建 GDrive OAuth 服务。 -func NewSoraGDriveOAuthService(settingService *SettingService) *SoraGDriveOAuthService { - return &SoraGDriveOAuthService{ - settingService: settingService, - } +func NewSoraGDriveOAuthService(_ *SettingService) *SoraGDriveOAuthService { + return &SoraGDriveOAuthService{} } // GenerateAuthURL 生成 Google OAuth 授权 URL。 diff --git a/backend/internal/service/sora_gdrive_storage.go b/backend/internal/service/sora_gdrive_storage.go index d71abf3222..739bbbfe0b 100644 --- a/backend/internal/service/sora_gdrive_storage.go +++ b/backend/internal/service/sora_gdrive_storage.go @@ -153,7 +153,9 @@ func (s *SoraGDriveStorage) buildOAuth2Service(ctx context.Context, profile *Sor } func (s *SoraGDriveStorage) buildServiceAccountService(ctx context.Context, profile *SoraS3Profile) (*drive.Service, error) { - creds, err := google.CredentialsFromJSON(ctx, []byte(profile.ServiceAccountJSON), drive.DriveFileScope) + creds, err := google.CredentialsFromJSONWithParams(ctx, []byte(profile.ServiceAccountJSON), google.CredentialsParams{ + Scopes: []string{drive.DriveFileScope}, + }) if err != nil { return nil, fmt.Errorf("parse service account json: %w", err) } diff --git a/backend/internal/service/sora_generation_service.go b/backend/internal/service/sora_generation_service.go index 1b5aa239a1..71773e3407 100644 --- a/backend/internal/service/sora_generation_service.go +++ b/backend/internal/service/sora_generation_service.go @@ -35,9 +35,9 @@ type soraGenerationRepoConditionalUpdater interface { // SoraGenerationService 管理 Sora 客户端的生成记录 CRUD。 type SoraGenerationService struct { - genRepo SoraGenerationRepository - objectStorage SoraObjectStorage - quotaService *SoraQuotaService + genRepo SoraGenerationRepository + objectStorage SoraObjectStorage + quotaService *SoraQuotaService } // NewSoraGenerationService 创建生成记录服务。