You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

38 lines
917 B

package model
type LocalProxy struct {
BaseModel
Port uint `json:"port"`
ProxyType string `json:"proxyType"`
Domain string `json:"domain"`
Path string `json:"path"`
Status bool `json:"status"`
}
func (*LocalProxy) TableName() string {
return "local_proxy"
}
func GetLocalProxiesOn() ([]LocalProxy, error) {
var proxies []LocalProxy
err := Db.Where("status = ?", true).Find(&proxies).Error
return proxies, err
}
// GetLocalProxies 获取所有 LocalProxy,支持分页
func GetLocalProxies(page, limit int) ([]LocalProxy, int64, error) {
var proxies []LocalProxy
var total int64
// 先计算总数
if err := Db.Model(&LocalProxy{}).Count(&total).Error; err != nil {
return nil, 0, err
}
// 再进行分页查询
offset := (page - 1) * limit
if err := Db.Limit(limit).Offset(offset).Find(&proxies).Error; err != nil {
return nil, 0, err
}
return proxies, total, nil
}