mirror of
https://github.com/Wei-Shaw/sub2api.git
synced 2026-09-24 16:05:44 +08:00
fix: resolve golangci-lint errors (gofmt, staticcheck, unused)
- Fix struct field alignment in dto/types.go, settings_view.go, sora_generation_service.go for gofmt compliance - Remove embedded field "Account" from selector in account_handler.go (QF1008) - Remove unused settingService field from SoraGDriveOAuthService - Replace deprecated google.CredentialsFromJSON with CredentialsFromJSONWithParams (SA1019) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
|
||||
@@ -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"`
|
||||
|
||||
@@ -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。
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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 创建生成记录服务。
|
||||
|
||||
Reference in New Issue
Block a user