feat(backend): 增强使用统计和API密钥功能

- 优化使用统计处理逻辑
- 增强API密钥仓储层功能
- 改进账户使用服务
- 完善API契约测试覆盖
This commit is contained in:
IanShaw027
2025-12-27 16:03:57 +08:00
parent 36a86e9ab4
commit 227d506c53
6 changed files with 83 additions and 21 deletions

View File

@@ -48,6 +48,10 @@ type UsageLogRepository interface {
// Account stats
GetAccountUsageStats(ctx context.Context, accountID int64, startTime, endTime time.Time) (*usagestats.AccountUsageStatsResponse, error)
// Aggregated stats (optimized)
GetUserStatsAggregated(ctx context.Context, userID int64, startTime, endTime time.Time) (*usagestats.UsageStats, error)
GetApiKeyStatsAggregated(ctx context.Context, apiKeyID int64, startTime, endTime time.Time) (*usagestats.UsageStats, error)
}
// usageCache 用于缓存usage数据