Commit 1e1f3c0c authored by Forest's avatar Forest
Browse files

ci(backend): 添加 gofmt 配置

parent 1fab9204
...@@ -515,11 +515,11 @@ func (s *PricingService) matchByModelFamily(model string) *LiteLLMModelPricing { ...@@ -515,11 +515,11 @@ func (s *PricingService) matchByModelFamily(model string) *LiteLLMModelPricing {
} }
// GetStatus 获取服务状态 // GetStatus 获取服务状态
func (s *PricingService) GetStatus() map[string]interface{} { func (s *PricingService) GetStatus() map[string]any {
s.mu.RLock() s.mu.RLock()
defer s.mu.RUnlock() defer s.mu.RUnlock()
return map[string]interface{}{ return map[string]any{
"model_count": len(s.pricingData), "model_count": len(s.pricingData),
"last_updated": s.lastUpdated, "last_updated": s.lastUpdated,
"local_hash": s.localHash[:min(8, len(s.localHash))], "local_hash": s.localHash[:min(8, len(s.localHash))],
......
...@@ -359,12 +359,12 @@ func (s *RedeemService) Delete(ctx context.Context, id int64) error { ...@@ -359,12 +359,12 @@ func (s *RedeemService) Delete(ctx context.Context, id int64) error {
} }
// GetStats 获取兑换码统计信息 // GetStats 获取兑换码统计信息
func (s *RedeemService) GetStats(ctx context.Context) (map[string]interface{}, error) { func (s *RedeemService) GetStats(ctx context.Context) (map[string]any, error) {
// TODO: 实现统计逻辑 // TODO: 实现统计逻辑
// 统计未使用、已使用的兑换码数量 // 统计未使用、已使用的兑换码数量
// 统计总面值等 // 统计总面值等
stats := map[string]interface{}{ stats := map[string]any{
"total_codes": 0, "total_codes": 0,
"unused_codes": 0, "unused_codes": 0,
"used_codes": 0, "used_codes": 0,
......
...@@ -19,7 +19,7 @@ type TokenRefresher interface { ...@@ -19,7 +19,7 @@ type TokenRefresher interface {
// Refresh 执行token刷新,返回更新后的credentials // Refresh 执行token刷新,返回更新后的credentials
// 注意:返回的map应该保留原有credentials中的所有字段,只更新token相关字段 // 注意:返回的map应该保留原有credentials中的所有字段,只更新token相关字段
Refresh(ctx context.Context, account *model.Account) (map[string]interface{}, error) Refresh(ctx context.Context, account *model.Account) (map[string]any, error)
} }
// ClaudeTokenRefresher 处理Anthropic/Claude OAuth token刷新 // ClaudeTokenRefresher 处理Anthropic/Claude OAuth token刷新
...@@ -61,14 +61,14 @@ func (r *ClaudeTokenRefresher) NeedsRefresh(account *model.Account, refreshWindo ...@@ -61,14 +61,14 @@ func (r *ClaudeTokenRefresher) NeedsRefresh(account *model.Account, refreshWindo
// Refresh 执行token刷新 // Refresh 执行token刷新
// 保留原有credentials中的所有字段,只更新token相关字段 // 保留原有credentials中的所有字段,只更新token相关字段
func (r *ClaudeTokenRefresher) Refresh(ctx context.Context, account *model.Account) (map[string]interface{}, error) { func (r *ClaudeTokenRefresher) Refresh(ctx context.Context, account *model.Account) (map[string]any, error) {
tokenInfo, err := r.oauthService.RefreshAccountToken(ctx, account) tokenInfo, err := r.oauthService.RefreshAccountToken(ctx, account)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// 保留现有credentials中的所有字段 // 保留现有credentials中的所有字段
newCredentials := make(map[string]interface{}) newCredentials := make(map[string]any)
for k, v := range account.Credentials { for k, v := range account.Credentials {
newCredentials[k] = v newCredentials[k] = v
} }
......
...@@ -195,7 +195,7 @@ func (s *UsageService) GetStatsByModel(ctx context.Context, modelName string, st ...@@ -195,7 +195,7 @@ func (s *UsageService) GetStatsByModel(ctx context.Context, modelName string, st
} }
// GetDailyStats 获取每日使用统计(最近N天) // GetDailyStats 获取每日使用统计(最近N天)
func (s *UsageService) GetDailyStats(ctx context.Context, userID int64, days int) ([]map[string]interface{}, error) { func (s *UsageService) GetDailyStats(ctx context.Context, userID int64, days int) ([]map[string]any, error) {
endTime := time.Now() endTime := time.Now()
startTime := endTime.AddDate(0, 0, -days) startTime := endTime.AddDate(0, 0, -days)
...@@ -227,13 +227,13 @@ func (s *UsageService) GetDailyStats(ctx context.Context, userID int64, days int ...@@ -227,13 +227,13 @@ func (s *UsageService) GetDailyStats(ctx context.Context, userID int64, days int
} }
// 计算平均值并转换为数组 // 计算平均值并转换为数组
result := make([]map[string]interface{}, 0, len(dailyStats)) result := make([]map[string]any, 0, len(dailyStats))
for date, stats := range dailyStats { for date, stats := range dailyStats {
if stats.TotalRequests > 0 { if stats.TotalRequests > 0 {
stats.AverageDurationMs /= float64(stats.TotalRequests) stats.AverageDurationMs /= float64(stats.TotalRequests)
} }
result = append(result, map[string]interface{}{ result = append(result, map[string]any{
"date": date, "date": date,
"total_requests": stats.TotalRequests, "total_requests": stats.TotalRequests,
"total_input_tokens": stats.TotalInputTokens, "total_input_tokens": stats.TotalInputTokens,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment