You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
go-library/service/meituan/poi.area.go

47 lines
1.4 KiB

3 years ago
package meituan
import (
2 years ago
"context"
1 year ago
"github.com/dtapps/go-library/utils/gojson"
2 years ago
"github.com/dtapps/go-library/utils/gorequest"
3 years ago
"net/http"
)
type PoiAreaResponse struct {
Code int `json:"code"`
Data []struct {
Area []struct {
Name string `json:"name"` // 商圈名称
ID int `json:"id"` // 商圈id
} `json:"area"`
Name string `json:"name"` // 行政区名称
ID int `json:"id"` // 行政区id
} `json:"data"`
}
type PoiAreaResult struct {
2 years ago
Result PoiAreaResponse // 结果
Body []byte // 内容
Http gorequest.Response // 请求
Err error // 错误
3 years ago
}
func newPoiAreaResult(result PoiAreaResponse, body []byte, http gorequest.Response, err error) *PoiAreaResult {
return &PoiAreaResult{Result: result, Body: body, Http: http, Err: err}
3 years ago
}
// PoiArea 基础数据 - 商圈接口
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiAreaCityid1
2 years ago
func (c *Client) PoiArea(ctx context.Context, cityID int) *PoiAreaResult {
3 years ago
// 参数
2 years ago
param := gorequest.NewParams()
3 years ago
param.Set("cityid", cityID)
2 years ago
params := gorequest.NewParamsWith(param)
3 years ago
// 请求
2 years ago
request, err := c.request(ctx, apiUrl+"/poi/area", params, http.MethodGet)
3 years ago
// 定义
var response PoiAreaResponse
1 year ago
err = gojson.Unmarshal(request.ResponseBody, &response)
return newPoiAreaResult(response, request.ResponseBody, request, err)
3 years ago
}