mirror of
				https://github.com/TeaOSLab/EdgeAPI.git
				synced 2025-11-04 07:50:25 +08:00 
			
		
		
		
	增加批量查询IP信息API
This commit is contained in:
		@@ -1,5 +1,10 @@
 | 
			
		||||
package iplibrary
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"github.com/iwind/TeaGo/lists"
 | 
			
		||||
	"strings"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
type Result struct {
 | 
			
		||||
	CityId   int64
 | 
			
		||||
	Country  string
 | 
			
		||||
@@ -8,3 +13,17 @@ type Result struct {
 | 
			
		||||
	City     string
 | 
			
		||||
	ISP      string
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (this *Result) Summary() string {
 | 
			
		||||
	pieces := []string{}
 | 
			
		||||
	if len(this.Country) > 0 {
 | 
			
		||||
		pieces = append(pieces, this.Country)
 | 
			
		||||
	}
 | 
			
		||||
	if len(this.Province) > 0 && !lists.ContainsString(pieces, this.Province) {
 | 
			
		||||
		pieces = append(pieces, this.Province)
 | 
			
		||||
	}
 | 
			
		||||
	if len(this.City) > 0 && !lists.ContainsString(pieces, this.City) && !lists.ContainsString(pieces, strings.TrimSuffix(this.Province, "市")) {
 | 
			
		||||
		pieces = append(pieces, this.City)
 | 
			
		||||
	}
 | 
			
		||||
	return strings.Join(pieces, " ")
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user