-
Notifications
You must be signed in to change notification settings - Fork 4
/
reader_result.go
97 lines (84 loc) · 1.76 KB
/
reader_result.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
package iplibrary
type QueryResult struct {
item *ipItem
meta *Meta
}
func (this *QueryResult) IsOk() bool {
return this.item != nil
}
func (this *QueryResult) CountryId() int64 {
if this.item != nil {
return this.item.countryId
}
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
}
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
}
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
}
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 ""
}