parent
2a046f32ed
commit
e2b7a2f0ef
@ -1,121 +0,0 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type OpenapiPoiCategoryResult struct {
|
||||
Code int `json:"code"`
|
||||
Data []struct {
|
||||
Name string `json:"name"`
|
||||
Subcate []struct {
|
||||
Name string `json:"name"` // 品类名称
|
||||
ID int `json:"id"` // 品类id
|
||||
} `json:"subcate"`
|
||||
ID int `json:"id"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
// OpenapiPoiCategory 基础数据 - 品类接口 https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiDistrictCityid1
|
||||
func (app *App) OpenapiPoiCategory(cityID int) (result OpenapiPoiCategoryResult, err error) {
|
||||
|
||||
param := NewParams()
|
||||
param.Set("cityid", cityID)
|
||||
|
||||
// 参数
|
||||
params := app.NewParamsWith(param)
|
||||
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/category", params, http.MethodGet)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(body, &result); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type OpenapiPoiAreaResult 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"`
|
||||
}
|
||||
|
||||
// OpenapiPoiArea 基础数据 - 商圈接口 https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiAreaCityid1
|
||||
func (app *App) OpenapiPoiArea(cityID int) (result OpenapiPoiAreaResult, err error) {
|
||||
|
||||
param := NewParams()
|
||||
param.Set("cityid", cityID)
|
||||
|
||||
// 参数
|
||||
params := app.NewParamsWith(param)
|
||||
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/area", params, http.MethodGet)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(body, &result); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type OpenapiPoiDistrictResult struct {
|
||||
Code int `json:"code"` // 状态码 0表示请求正常
|
||||
Data []struct {
|
||||
Name string `json:"name"` // 行政区名称
|
||||
ID int `json:"id"` // 行政区id
|
||||
} `json:"data"` // 返回行政区列表
|
||||
}
|
||||
|
||||
// OpenapiPoiDistrict 基础数据 - 城市的行政区接口 https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiDistrictCityid1
|
||||
func (app *App) OpenapiPoiDistrict(cityID int) (result OpenapiPoiDistrictResult, err error) {
|
||||
|
||||
param := NewParams()
|
||||
param.Set("cityid", cityID)
|
||||
|
||||
// 参数
|
||||
params := app.NewParamsWith(param)
|
||||
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/district", params, http.MethodGet)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(body, &result); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type OpenapiPoiCityResult struct {
|
||||
Code int `json:"code"` // 状态码 0表示请求正常
|
||||
Data []struct {
|
||||
Pinyin string `json:"pinyin"` // 城市拼音
|
||||
Name string `json:"name"` // 城市名称
|
||||
ID int `json:"id"` // 城市id
|
||||
} `json:"data"` // 返回城市列表
|
||||
}
|
||||
|
||||
// OpenapiPoiCity 基础数据 - 开放城市接口 https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiCity
|
||||
func (app *App) OpenapiPoiCity() (result OpenapiPoiCityResult, err error) {
|
||||
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/city", map[string]interface{}{}, http.MethodGet)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if err = json.Unmarshal(body, &result); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"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 {
|
||||
Result PoiAreaResponse // 结果
|
||||
Body []byte // 内容
|
||||
Err error // 错误
|
||||
}
|
||||
|
||||
func NewPoiAreaResult(result PoiAreaResponse, body []byte, err error) *PoiAreaResult {
|
||||
return &PoiAreaResult{Result: result, Body: body, Err: err}
|
||||
}
|
||||
|
||||
// PoiArea 基础数据 - 商圈接口
|
||||
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiAreaCityid1
|
||||
func (app *App) PoiArea(cityID int) *PoiAreaResult {
|
||||
// 参数
|
||||
param := NewParams()
|
||||
param.Set("cityid", cityID)
|
||||
params := app.NewParamsWith(param)
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/area", params, http.MethodGet)
|
||||
// 定义
|
||||
var response PoiAreaResponse
|
||||
err = json.Unmarshal(body, &response)
|
||||
return NewPoiAreaResult(response, body, err)
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type PoiCategoryResponse struct {
|
||||
Code int `json:"code"`
|
||||
Data []struct {
|
||||
Name string `json:"name"`
|
||||
Subcate []struct {
|
||||
Name string `json:"name"` // 品类名称
|
||||
ID int `json:"id"` // 品类id
|
||||
} `json:"subcate"`
|
||||
ID int `json:"id"`
|
||||
} `json:"data"`
|
||||
}
|
||||
|
||||
type PoiCategoryResult struct {
|
||||
Result PoiCategoryResponse // 结果
|
||||
Body []byte // 内容
|
||||
Err error // 错误
|
||||
}
|
||||
|
||||
func NewPoiCategoryResult(result PoiCategoryResponse, body []byte, err error) *PoiCategoryResult {
|
||||
return &PoiCategoryResult{Result: result, Body: body, Err: err}
|
||||
}
|
||||
|
||||
// PoiCategory 基础数据 - 品类接口
|
||||
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiDistrictCityid1
|
||||
func (app *App) PoiCategory(cityID int) *PoiCategoryResult {
|
||||
// 参数
|
||||
param := NewParams()
|
||||
param.Set("cityid", cityID)
|
||||
params := app.NewParamsWith(param)
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/category", params, http.MethodGet)
|
||||
// 定义
|
||||
var response PoiCategoryResponse
|
||||
err = json.Unmarshal(body, &response)
|
||||
return NewPoiCategoryResult(response, body, err)
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type PoiCityResponse struct {
|
||||
Code int `json:"code"` // 状态码 0表示请求正常
|
||||
Data []struct {
|
||||
Pinyin string `json:"pinyin"` // 城市拼音
|
||||
Name string `json:"name"` // 城市名称
|
||||
ID int `json:"id"` // 城市id
|
||||
} `json:"data"` // 返回城市列表
|
||||
}
|
||||
|
||||
type PoiCityResult struct {
|
||||
Result PoiCityResponse // 结果
|
||||
Body []byte // 内容
|
||||
Err error // 错误
|
||||
}
|
||||
|
||||
func NewPoiCityResult(result PoiCityResponse, body []byte, err error) *PoiCityResult {
|
||||
return &PoiCityResult{Result: result, Body: body, Err: err}
|
||||
}
|
||||
|
||||
// PoiCity 基础数据 - 开放城市接口
|
||||
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiCity
|
||||
func (app *App) PoiCity() *PoiCityResult {
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/city", map[string]interface{}{}, http.MethodGet)
|
||||
// 定义
|
||||
var response PoiCityResponse
|
||||
err = json.Unmarshal(body, &response)
|
||||
return NewPoiCityResult(response, body, err)
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package meituan
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type PoiDistrictResponse struct {
|
||||
Code int `json:"code"` // 状态码 0表示请求正常
|
||||
Data []struct {
|
||||
Name string `json:"name"` // 行政区名称
|
||||
ID int `json:"id"` // 行政区id
|
||||
} `json:"data"` // 返回行政区列表
|
||||
}
|
||||
|
||||
type PoiDistrictResult struct {
|
||||
Result PoiDistrictResponse // 结果
|
||||
Body []byte // 内容
|
||||
Err error // 错误
|
||||
}
|
||||
|
||||
func NewPoiDistrictResult(result PoiDistrictResponse, body []byte, err error) *PoiDistrictResult {
|
||||
return &PoiDistrictResult{Result: result, Body: body, Err: err}
|
||||
}
|
||||
|
||||
// PoiDistrict 基础数据 - 城市的行政区接口
|
||||
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiDistrictCityid1
|
||||
func (app *App) PoiDistrict(cityID int) *PoiDistrictResult {
|
||||
// 参数
|
||||
param := NewParams()
|
||||
param.Set("cityid", cityID)
|
||||
params := app.NewParamsWith(param)
|
||||
// 请求
|
||||
body, err := app.request("https://openapi.meituan.com/poi/district", params, http.MethodGet)
|
||||
// 定义
|
||||
var response PoiDistrictResponse
|
||||
err = json.Unmarshal(body, &response)
|
||||
return NewPoiDistrictResult(response, body, err)
|
||||
}
|
Loading…
Reference in new issue