mirror of
https://github.com/TeaOSLab/EdgeCommon.git
synced 2025-11-11 10:10:27 +08:00
IP库阶段性提交(未完成)
This commit is contained in:
@@ -4,6 +4,7 @@ package iplibrary
|
||||
|
||||
type QueryResult struct {
|
||||
item *ipItem
|
||||
meta *Meta
|
||||
}
|
||||
|
||||
func (this *QueryResult) IsOk() bool {
|
||||
@@ -17,6 +18,16 @@ func (this *QueryResult) CountryId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *QueryResult) CountryName() string {
|
||||
if this.item.countryId > 0 {
|
||||
var country = this.meta.CountryWithId(this.item.countryId)
|
||||
if country != nil {
|
||||
return country.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *QueryResult) ProvinceId() int64 {
|
||||
if this.item != nil {
|
||||
return this.item.provinceId
|
||||
@@ -24,6 +35,16 @@ func (this *QueryResult) ProvinceId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *QueryResult) ProvinceName() string {
|
||||
if this.item.provinceId > 0 {
|
||||
var province = this.meta.ProvinceWithId(this.item.provinceId)
|
||||
if province != nil {
|
||||
return province.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *QueryResult) CityId() int64 {
|
||||
if this.item != nil {
|
||||
return this.item.cityId
|
||||
@@ -31,6 +52,16 @@ func (this *QueryResult) CityId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *QueryResult) CityName() string {
|
||||
if this.item.cityId > 0 {
|
||||
var city = this.meta.CityWithId(this.item.cityId)
|
||||
if city != nil {
|
||||
return city.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *QueryResult) TownId() int64 {
|
||||
if this.item != nil {
|
||||
return this.item.townId
|
||||
@@ -38,9 +69,29 @@ func (this *QueryResult) TownId() int64 {
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *QueryResult) TownName() string {
|
||||
if this.item.townId > 0 {
|
||||
var town = this.meta.TownWithId(this.item.townId)
|
||||
if town != nil {
|
||||
return town.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (this *QueryResult) ProviderId() int64 {
|
||||
if this.item != nil {
|
||||
return this.item.providerId
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (this *QueryResult) ProviderName() string {
|
||||
if this.item.providerId > 0 {
|
||||
var provider = this.meta.ProviderWithId(this.item.providerId)
|
||||
if provider != nil {
|
||||
return provider.Name
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user