fix(test): 修复 CI 测试和 lint 错误
- 为所有 mock 实现添加 GetByIDs 方法以满足 AccountRepository 接口 - 重构 account_handler.go 中的类型断言,使用类型安全的变量 - 修复 gofmt 格式问题
This commit is contained in:
@@ -1099,12 +1099,8 @@ func (h *AccountHandler) BatchRefreshTier(c *gin.Context) {
|
||||
g.SetLimit(maxConcurrency)
|
||||
|
||||
var mu sync.Mutex
|
||||
results := gin.H{
|
||||
"total": len(accounts),
|
||||
"success": 0,
|
||||
"failed": 0,
|
||||
"errors": []gin.H{},
|
||||
}
|
||||
var successCount, failedCount int
|
||||
var errors []gin.H
|
||||
|
||||
for _, account := range accounts {
|
||||
acc := account // 闭包捕获
|
||||
@@ -1112,8 +1108,8 @@ func (h *AccountHandler) BatchRefreshTier(c *gin.Context) {
|
||||
_, extra, creds, err := h.geminiOAuthService.RefreshAccountGoogleOneTier(gctx, acc)
|
||||
if err != nil {
|
||||
mu.Lock()
|
||||
results["failed"] = results["failed"].(int) + 1
|
||||
results["errors"] = append(results["errors"].([]gin.H), gin.H{
|
||||
failedCount++
|
||||
errors = append(errors, gin.H{
|
||||
"account_id": acc.ID,
|
||||
"error": err.Error(),
|
||||
})
|
||||
@@ -1128,13 +1124,13 @@ func (h *AccountHandler) BatchRefreshTier(c *gin.Context) {
|
||||
|
||||
mu.Lock()
|
||||
if updateErr != nil {
|
||||
results["failed"] = results["failed"].(int) + 1
|
||||
results["errors"] = append(results["errors"].([]gin.H), gin.H{
|
||||
failedCount++
|
||||
errors = append(errors, gin.H{
|
||||
"account_id": acc.ID,
|
||||
"error": updateErr.Error(),
|
||||
})
|
||||
} else {
|
||||
results["success"] = results["success"].(int) + 1
|
||||
successCount++
|
||||
}
|
||||
mu.Unlock()
|
||||
|
||||
@@ -1147,5 +1143,12 @@ func (h *AccountHandler) BatchRefreshTier(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
results := gin.H{
|
||||
"total": len(accounts),
|
||||
"success": successCount,
|
||||
"failed": failedCount,
|
||||
"errors": errors,
|
||||
}
|
||||
|
||||
response.Success(c, results)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user