mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	优化IP名单使用IP搜索查询速度
This commit is contained in:
		@@ -14,6 +14,7 @@ import (
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"github.com/iwind/TeaGo/types"
 | 
			
		||||
	"math"
 | 
			
		||||
	"net"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
@@ -498,8 +499,12 @@ func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, ke
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(keyword) > 0 {
 | 
			
		||||
		if net.ParseIP(keyword) != nil { // 是一个IP地址
 | 
			
		||||
			query.Attr("ipFrom", keyword)
 | 
			
		||||
		} else {
 | 
			
		||||
			query.Like("ipFrom", dbutils.QuoteLike(keyword))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(ip) > 0 {
 | 
			
		||||
		query.Attr("ipFrom", ip)
 | 
			
		||||
	}
 | 
			
		||||
@@ -540,8 +545,12 @@ func (this *IPItemDAO) ListAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, key
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(keyword) > 0 {
 | 
			
		||||
		if net.ParseIP(keyword) != nil { // 是一个IP地址
 | 
			
		||||
			query.Attr("ipFrom", keyword)
 | 
			
		||||
		} else {
 | 
			
		||||
			query.Like("ipFrom", dbutils.QuoteLike(keyword))
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(ip) > 0 {
 | 
			
		||||
		query.Attr("ipFrom", ip)
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user