package services import ( m "platform/web/models" q "platform/web/queries" "time" ) var Proxy = &proxyService{} type proxyService struct{} func (s *proxyService) AllProxies(proxyType m.ProxyType, channels bool) ([]*m.Proxy, error) { proxies, err := q.Proxy.Where( q.Proxy.Type.Eq(int(proxyType)), q.Proxy.Status.Eq(int(m.ProxyStatusOnline)), ).Preload( q.Proxy.Channels.On(q.Channel.ExpiredAt.Gte(time.Now())), ).Find() if err != nil { return nil, err } return proxies, nil }