-
Notifications
You must be signed in to change notification settings - Fork 3
/
movie_info_get_city_area.go
45 lines (40 loc) · 1.42 KB
/
movie_info_get_city_area.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
package pintoto
import (
"context"
"github.com/dtapps/go-library/utils/gojson"
"github.com/dtapps/go-library/utils/gorequest"
)
type GetCityAreaResponse struct {
Code int `json:"code"`
Message string `json:"message"`
Data struct {
List []struct {
AreaId int `json:"areaId"` // 区域id
AreaName string `json:"areaName"` // 区域名
} `json:"list"`
} `json:"data"`
Success bool `json:"success"`
}
type GetCityAreaResult struct {
Result GetCityAreaResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
}
func newGetCityAreaResult(result GetCityAreaResponse, body []byte, http gorequest.Response) *GetCityAreaResult {
return &GetCityAreaResult{Result: result, Body: body, Http: http}
}
// GetCityArea 城市下区域
// https://www.showdoc.com.cn/1154868044931571/6243539682553126
func (c *Client) GetCityArea(ctx context.Context, cityId int, notMustParams ...gorequest.Params) (*GetCityAreaResult, error) {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
params.Set("cityId", cityId)
// 请求
request, err := c.request(ctx, apiUrl+"/movieapi/movie-info/get-city-area", params)
if err != nil {
return newGetCityAreaResult(GetCityAreaResponse{}, request.ResponseBody, request), err
}
var response GetCityAreaResponse
err = gojson.Unmarshal(request.ResponseBody, &response)
return newGetCityAreaResult(response, request.ResponseBody, request), err
}