mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 16:00:24 +08:00 
			
		
		
		
	修复用户端无法查看IP名单的Bug
This commit is contained in:
		@@ -365,8 +365,10 @@ func (this *IPItemDAO) CountIPItemsWithListId(tx *dbs.Tx, listId int64, sourceUs
 | 
			
		||||
		State(IPItemStateEnabled).
 | 
			
		||||
		Attr("listId", listId)
 | 
			
		||||
	if sourceUserId > 0 {
 | 
			
		||||
		if listId <= 0 || listId == firewallconfigs.GlobalListId {
 | 
			
		||||
			query.Attr("sourceUserId", sourceUserId)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(keyword) > 0 {
 | 
			
		||||
		query.Where("(ipFrom LIKE :keyword OR ipTo LIKE :keyword)").
 | 
			
		||||
			Param("keyword", dbutils.QuoteLike(keyword))
 | 
			
		||||
@@ -389,8 +391,10 @@ func (this *IPItemDAO) ListIPItemsWithListId(tx *dbs.Tx, listId int64, sourceUse
 | 
			
		||||
		State(IPItemStateEnabled).
 | 
			
		||||
		Attr("listId", listId)
 | 
			
		||||
	if sourceUserId > 0 {
 | 
			
		||||
		if listId <= 0 || listId == firewallconfigs.GlobalListId {
 | 
			
		||||
			query.Attr("sourceUserId", sourceUserId)
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(keyword) > 0 {
 | 
			
		||||
		query.Where("(ipFrom LIKE :keyword OR ipTo LIKE :keyword)").
 | 
			
		||||
			Param("keyword", dbutils.QuoteLike(keyword))
 | 
			
		||||
@@ -482,9 +486,14 @@ func (this *IPItemDAO) ExistsEnabledItem(tx *dbs.Tx, itemId int64) (bool, error)
 | 
			
		||||
func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string) (int64, error) {
 | 
			
		||||
	var query = this.Query(tx)
 | 
			
		||||
	if sourceUserId > 0  {
 | 
			
		||||
		if listId <= 0 {
 | 
			
		||||
			query.Where("((listId=" +types.String(firewallconfigs.GlobalListId)+ " AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
 | 
			
		||||
			query.Param("sourceUserId", sourceUserId)
 | 
			
		||||
		} else if listId == firewallconfigs.GlobalListId {
 | 
			
		||||
			query.Attr("sourceUserId", sourceUserId)
 | 
			
		||||
			query.UseIndex("sourceUserId")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(keyword) > 0 {
 | 
			
		||||
		query.Like("ipFrom", dbutils.QuoteLike(keyword))
 | 
			
		||||
	}
 | 
			
		||||
@@ -519,9 +528,14 @@ func (this *IPItemDAO) CountAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, ke
 | 
			
		||||
func (this *IPItemDAO) ListAllEnabledIPItems(tx *dbs.Tx, sourceUserId int64, keyword string, ip string, listId int64, unread bool, eventLevel string, listType string, offset int64, size int64) (result []*IPItem, err error) {
 | 
			
		||||
	var query = this.Query(tx)
 | 
			
		||||
	if sourceUserId > 0  {
 | 
			
		||||
		if listId <= 0 {
 | 
			
		||||
			query.Where("((listId=" +types.String(firewallconfigs.GlobalListId)+ " AND sourceUserId=:sourceUserId) OR listId IN (SELECT id FROM " + SharedIPListDAO.Table + " WHERE userId=:sourceUserId AND state=1))")
 | 
			
		||||
			query.Param("sourceUserId", sourceUserId)
 | 
			
		||||
		} else if listId == firewallconfigs.GlobalListId {
 | 
			
		||||
			query.Attr("sourceUserId", sourceUserId)
 | 
			
		||||
			query.UseIndex("sourceUserId")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	if len(keyword) > 0 {
 | 
			
		||||
		query.Like("ipFrom", dbutils.QuoteLike(keyword))
 | 
			
		||||
	}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user