-
Notifications
You must be signed in to change notification settings - Fork 3
/
movie_info_get_city_list.go
47 lines (41 loc) · 1.5 KB
/
movie_info_get_city_list.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
package pintoto
import (
"context"
"github.com/dtapps/go-library/utils/gojson"
"github.com/dtapps/go-library/utils/gorequest"
)
type GetCityListResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
List []GetCityListResponseDataList `json:"list"`
} `json:"data"`
Success bool `json:"success"`
}
type GetCityListResponseDataList struct {
PinYin string `json:"pinYin"` // 城市首字母
RegionName string `json:"regionName"` // 城市名
CityId int `json:"cityId"` // 城市id
}
type GetCityListResult struct {
Result GetCityListResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newGetCityListResult(result GetCityListResponse, body []byte, http gorequest.Response) *GetCityListResult {
return &GetCityListResult{Result: result, Body: body, Http: http}
}
// GetCityList 城市列表
// https://www.showdoc.com.cn/1154868044931571/5865562425538244
func (c *Client) GetCityList(ctx context.Context, notMustParams ...gorequest.Params) (*GetCityListResult, error) {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求
request, err := c.request(ctx, apiUrl+"/movieapi/movie-info/get-city-list", params)
if err != nil {
return newGetCityListResult(GetCityListResponse{}, request.ResponseBody, request), err
}
var response GetCityListResponse
err = gojson.Unmarshal(request.ResponseBody, &response)
return newGetCityListResult(response, request.ResponseBody, request), err
}