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
package ikc
import (
"context"
"github.com/gogf/gf/encoding/gjson"
"github.com/gogf/gf/frame/g"
)
type addressIkc struct {
}
//Address 地址
var Address = addressIkc{}
type AddressProvinceRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
ProvinceCode string `json:"provinceCode"`
ProvinceName string `json:"provinceName"`
} `json:"data"`
}
//Province 省
func (addressIkc) Province(ctx context.Context) (res *AddressProvinceRes, err error) {
method := "address/v2/queryProvince"
result, err := post(ctx, method, g.Map{})
_ = gjson.New(result).Scan(&res)
return
}
type AddressCityRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
CityName string `json:"cityName"`
CityCode string `json:"cityCode"`
} `json:"data"`
}
//City 市
func (addressIkc) City(ctx context.Context, code string) (res *AddressCityRes, err error) {
method := "address/v2/queryCity"
result, err := post(ctx, method, g.Map{
"provinceCode": code,
})
_ = gjson.New(result).Scan(&res)
return
}
type AddressAreaRes struct {
ResultCode int `json:"resultCode"`
ResultMessage string `json:"resultMessage"`
Data []struct {
AreaCode string `json:"areaCode"`
AreaName string `json:"areaName"`
} `json:"data"`
}
//Area 区
func (addressIkc) Area(ctx context.Context, code string) (res *AddressAreaRes, err error) {
method := "address/v2/queryArea"
result, err := post(ctx, method, g.Map{
"cityCode": code,
})
_ = gjson.New(result).Scan(&res)
return
}