perf: batch fetch proxies for account export

This commit is contained in:
LLLLLLiulei
2026-02-05 18:40:49 +08:00
parent 0c660f8335
commit 0b45d48e85
8 changed files with 77 additions and 3 deletions

View File

@@ -269,6 +269,24 @@ func (s *stubAdminService) GetProxy(ctx context.Context, id int64) (*service.Pro
return &proxy, nil
}
func (s *stubAdminService) GetProxiesByIDs(ctx context.Context, ids []int64) ([]service.Proxy, error) {
if len(ids) == 0 {
return []service.Proxy{}, nil
}
out := make([]service.Proxy, 0, len(ids))
seen := make(map[int64]struct{}, len(ids))
for _, id := range ids {
seen[id] = struct{}{}
}
for i := range s.proxies {
proxy := s.proxies[i]
if _, ok := seen[proxy.ID]; ok {
out = append(out, proxy)
}
}
return out, nil
}
func (s *stubAdminService) CreateProxy(ctx context.Context, input *service.CreateProxyInput) (*service.Proxy, error) {
s.mu.Lock()
s.createdProxies = append(s.createdProxies, input)