Files
go-account-register/services/proxy_service.go

28 lines
453 B
Go

package services
import (
"go-account-register/models"
"go-account-register/utils"
"gorm.io/gorm"
)
type ProxyService struct {
db *gorm.DB
}
func InitProxyService() *ProxyService {
db := utils.GetDB()
return &ProxyService{db: db}
}
func (p *ProxyService) GetInfo() *models.Proxy {
var proxy models.Proxy
result := p.db.Model(&models.Proxy{}).Order("RAND()").Limit(1).Find(&proxy)
if result.Error != nil {
return nil
}
return &proxy
}