fix(usage): 使用日志事务和幂等性修复
- UsageLogRepository.Create 返回 inserted 标志 - UsageService 使用事务保证原子性 - 避免重复扣费(幂等重试场景) - 更新依赖注入和测试
This commit is contained in:
@@ -380,7 +380,7 @@ func newContractDeps(t *testing.T) *contractDeps {
|
||||
apiKeyService := service.NewApiKeyService(apiKeyRepo, userRepo, groupRepo, userSubRepo, apiKeyCache, cfg)
|
||||
|
||||
usageRepo := newStubUsageLogRepo()
|
||||
usageService := service.NewUsageService(usageRepo, userRepo)
|
||||
usageService := service.NewUsageService(usageRepo, userRepo, client)
|
||||
|
||||
settingRepo := newStubSettingRepo()
|
||||
settingService := service.NewSettingService(settingRepo, cfg)
|
||||
|
||||
Reference in New Issue
Block a user