- update request
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/tag Build is passing Details

master v1.0.6
李光春 2 years ago
parent 5a744b99f4
commit 39315b3ef8

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -25,7 +26,7 @@ func newApiGenerateLinkResult(result ApiGenerateLinkResponse, body []byte, http
// ApiGenerateLink 自助取链接口(新版)
// https://union.meituan.com/v2/apiDetail?id=25
func (c *Client) ApiGenerateLink(actId int64, sid string, linkType, shortLink int) *ApiGenerateLinkResult {
func (c *Client) ApiGenerateLink(ctx context.Context, actId int64, sid string, linkType, shortLink int) *ApiGenerateLinkResult {
// 参数
param := gorequest.NewParams()
param.Set("actId", actId) // 活动id可以在联盟活动列表中查看获取
@ -37,7 +38,7 @@ func (c *Client) ApiGenerateLink(actId int64, sid string, linkType, shortLink in
params := gorequest.NewParamsWith(param)
params["sign"] = c.getSign(c.config.Secret, params)
// 请求
request, err := c.request(apiUrl+"/api/generateLink", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/api/generateLink", params, http.MethodGet)
// 定义
var response ApiGenerateLinkResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"go.dtapp.net/gotime"
@ -34,7 +35,7 @@ func newApiGetQuaLitYsCoreBySidResult(result ApiGetQuaLitYsCoreBySidResponse, bo
// ApiGetQuaLitYsCoreBySid 优选sid质量分&复购率查询
// https://union.meituan.com/v2/apiDetail?id=28
func (c *Client) ApiGetQuaLitYsCoreBySid(notMustParams ...gorequest.Params) *ApiGetQuaLitYsCoreBySidResult {
func (c *Client) ApiGetQuaLitYsCoreBySid(ctx context.Context, notMustParams ...gorequest.Params) *ApiGetQuaLitYsCoreBySidResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求时刻10位时间戳(秒级)有效期60s
@ -42,7 +43,7 @@ func (c *Client) ApiGetQuaLitYsCoreBySid(notMustParams ...gorequest.Params) *Api
params["appkey"] = c.config.AppKey
params["sign"] = c.getSign(c.config.Secret, params)
// 请求
request, err := c.request(apiUrl+"/api/getqualityscorebysid", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/api/getqualityscorebysid", params, http.MethodGet)
// 定义
var response ApiGetQuaLitYsCoreBySidResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -25,7 +26,7 @@ func newApiMiniCodeResult(result ApiMiniCodeResponse, body []byte, http goreques
// ApiMiniCode 小程序生成二维码(新版)
// https://union.meituan.com/v2/apiDetail?id=26
func (c *Client) ApiMiniCode(actId int64, sid string) *ApiMiniCodeResult {
func (c *Client) ApiMiniCode(ctx context.Context, actId int64, sid string) *ApiMiniCodeResult {
// 参数
param := gorequest.NewParams()
param.Set("appkey", c.config.AppKey)
@ -35,7 +36,7 @@ func (c *Client) ApiMiniCode(actId int64, sid string) *ApiMiniCodeResult {
params := gorequest.NewParamsWith(param)
params["sign"] = c.getSign(c.config.Secret, params)
// 请求
request, err := c.request(apiUrl+"/api/miniCode", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/api/miniCode", params, http.MethodGet)
// 定义
var response ApiMiniCodeResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -47,14 +48,14 @@ func newApiOrderResult(result ApiOrderResponse, body []byte, http gorequest.Resp
// ApiOrder 单订单查询接口(新版)
// https://union.meituan.com/v2/apiDetail?id=24
func (c *Client) ApiOrder(notMustParams ...gorequest.Params) *ApiOrderResult {
func (c *Client) ApiOrder(ctx context.Context, notMustParams ...gorequest.Params) *ApiOrderResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求时刻10位时间戳(秒级)有效期60s
params["appkey"] = c.config.AppKey
params["sign"] = c.getSign(c.config.Secret, params)
// 请求
request, err := c.request(apiUrl+"/api/order", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/api/order", params, http.MethodGet)
// 定义
var response ApiOrderResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"go.dtapp.net/gotime"
@ -46,7 +47,7 @@ func newApiOrderListResult(result ApiOrderListResponse, body []byte, http gorequ
// ApiOrderList 订单列表查询接口(新版)
// https://union.meituan.com/v2/apiDetail?id=23
func (c *Client) ApiOrderList(notMustParams ...gorequest.Params) *ApiOrderListResult {
func (c *Client) ApiOrderList(ctx context.Context, notMustParams ...gorequest.Params) *ApiOrderListResult {
// 参数
params := gorequest.NewParamsWith(notMustParams...)
// 请求时刻10位时间戳(秒级)有效期60s
@ -54,7 +55,7 @@ func (c *Client) ApiOrderList(notMustParams ...gorequest.Params) *ApiOrderListRe
params["appkey"] = c.config.AppKey
params["sign"] = c.getSign(c.config.Secret, params)
// 请求
request, err := c.request(apiUrl+"/api/orderList", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/api/orderList", params, http.MethodGet)
// 定义
var response ApiOrderListResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -8,4 +8,4 @@ const (
logTable = "meituan"
)
const Version = "1.0.5"
const Version = "1.0.6"

@ -4,8 +4,8 @@ go 1.19
require (
github.com/gin-gonic/gin v1.8.1
go.dtapp.net/dorm v1.0.14
go.dtapp.net/golog v1.0.21
go.dtapp.net/dorm v1.0.17
go.dtapp.net/golog v1.0.22
go.dtapp.net/gorequest v1.0.24
go.dtapp.net/gotime v1.0.5
gorm.io/gorm v1.23.8
@ -69,14 +69,14 @@ require (
go.dtapp.net/gostring v1.0.6 // indirect
go.dtapp.net/goxml v1.0.1 // indirect
go.mongodb.org/mongo-driver v1.10.1 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.22.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced // indirect
golang.org/x/net v0.0.0-20220811182439-13a9a731de15 // indirect
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 // indirect
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 // indirect
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab // indirect
golang.org/x/text v0.3.7 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect

@ -185,7 +185,6 @@ github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANyt
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/ipfs/go-detect-race v0.0.1 h1:qX/xay2W3E4Q1U7d9lNs1sU9nvguX0a7319XbyQ6cOk=
github.com/ipfs/go-detect-race v0.0.1/go.mod h1:8BNT7shDZPo99Q74BpGMK+4D8Mn4j46UU0LZ723meps=
github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0=
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
@ -212,7 +211,6 @@ github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5W
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A=
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
@ -468,7 +466,6 @@ github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhV
github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc h1:9lRDQMhESg+zvGYmW5DyG0UqvY96Bu5QYsTLvCHdrgo=
github.com/tmthrgd/go-hex v0.0.0-20190904060850-447a3041c3bc/go.mod h1:bciPuU6GHm1iF1pBvUfxfsH0Wmnc2VbpgvbI9ZWuIRs=
github.com/ugorji/go v1.2.7 h1:qYhyWUUd6WbiM+C6JZAUkIJt/1WrjzNHY9+KCIjVqTo=
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0=
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
@ -503,14 +500,14 @@ github.com/youmark/pkcs8 v0.0.0-20201027041543-1326539a0a0a/go.mod h1:ul22v+Nro/
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
go.dtapp.net/dorm v1.0.14 h1:HDsaMwKGlKFKt59Y3hPI9aVnSjfXOyjoHw2uoXErKEo=
go.dtapp.net/dorm v1.0.14/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM=
go.dtapp.net/dorm v1.0.17 h1:3VQKUl05CDxFg3T1c/M8wYf2I+H+oVGBDh4NCV30nn0=
go.dtapp.net/dorm v1.0.17/go.mod h1:bHG7BmgeLaAlc56myYF63lwZAIuMeWRAqHBb/L84dLM=
go.dtapp.net/goip v1.0.24 h1:62k3xt9I/YLUwA5tLp7YC8XPskkswc4RJrvxRRxjwIY=
go.dtapp.net/goip v1.0.24/go.mod h1:tps0yoq5kSykLGDb01vuai47hzAQ6nYUPFWLdlQA2Oo=
go.dtapp.net/gojson v1.0.1 h1:MHeSGlq1KxzL7rCkm18fhwW4GNORHohdDMmxY5PupKY=
go.dtapp.net/gojson v1.0.1/go.mod h1:TkkpTNxHBKxul0e7gC5MrL1K4ICFB9mQ7wHzjBah3/k=
go.dtapp.net/golog v1.0.21 h1:pSGmDz3SJTH7M/NvVLZb+YJd8uNl5g18aORibuaY2JU=
go.dtapp.net/golog v1.0.21/go.mod h1:Wxm2Kh77JN5zFDZ72el9E9c/YkoJnOvHVusB7SqvoC8=
go.dtapp.net/golog v1.0.22 h1:sOJr5f/iLk/6irT/RuwTQSTwvL2DR8SIhzMsKdHo0Ic=
go.dtapp.net/golog v1.0.22/go.mod h1:sbn2WQXmlukcZ4T3Kz9iWOSznL8H3RCkD+1nicZHMfI=
go.dtapp.net/gorandom v1.0.1 h1:IWfMClh1ECPvyUjlqD7MwLq4mZdUusD1qAwAdsvEJBs=
go.dtapp.net/gorandom v1.0.1/go.mod h1:ZPdgalKpvFV/ATQqR0k4ns/F/IpITAZpx6WkWirr5Y8=
go.dtapp.net/gorequest v1.0.24 h1:N2RJOpCXPWbsjfQ8iYJI1EYC2se3I4QhK1l94DSJsuE=
@ -533,8 +530,8 @@ go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
@ -605,8 +602,8 @@ golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwY
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210610132358-84b48f89b13b/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced h1:3dYNDff0VT5xj+mbj2XucFst9WKk6PdGOrb9n+SbIvw=
golang.org/x/net v0.0.0-20220809184613-07c6da5e1ced/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/net v0.0.0-20220811182439-13a9a731de15 h1:cik0bxZUSJVDyaHf1hZPSDsU8SZHGQZQMeueXCE7yBQ=
golang.org/x/net v0.0.0-20220811182439-13a9a731de15/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
@ -651,8 +648,8 @@ golang.org/x/sys v0.0.0-20210902050250-f475640dd07b/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664 h1:v1W7bwXHsnLLloWYTVEdvGvA7BHMeBYsPcF0GLDxIRs=
golang.org/x/sys v0.0.0-20220808155132-1c4a2a72c664/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab h1:2QkjZIsXupsJbJIdSjjUOgWK3aEtzyuh2mPt3l/CkeU=
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -31,13 +32,13 @@ func newPoiAreaResult(result PoiAreaResponse, body []byte, http gorequest.Respon
// PoiArea 基础数据 - 商圈接口
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiAreaCityid1
func (c *Client) PoiArea(cityID int) *PoiAreaResult {
func (c *Client) PoiArea(ctx context.Context, cityID int) *PoiAreaResult {
// 参数
param := gorequest.NewParams()
param.Set("cityid", cityID)
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(apiUrl+"/poi/area", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/poi/area", params, http.MethodGet)
// 定义
var response PoiAreaResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -31,13 +32,13 @@ func newPoiCategoryResult(result PoiCategoryResponse, body []byte, http goreques
// PoiCategory 基础数据 - 品类接口
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiDistrictCityid1
func (c *Client) PoiCategory(cityID int) *PoiCategoryResult {
func (c *Client) PoiCategory(ctx context.Context, cityID int) *PoiCategoryResult {
// 参数
param := gorequest.NewParams()
param.Set("cityid", cityID)
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(apiUrl+"/poi/category", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/poi/category", params, http.MethodGet)
// 定义
var response PoiCategoryResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -28,9 +29,9 @@ func newPoiCityResult(result PoiCityResponse, body []byte, http gorequest.Respon
// PoiCity 基础数据 - 开放城市接口
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiCity
func (c *Client) PoiCity() *PoiCityResult {
func (c *Client) PoiCity(ctx context.Context) *PoiCityResult {
// 请求
request, err := c.request(apiUrl+"/poi/city", map[string]interface{}{}, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/poi/city", map[string]interface{}{}, http.MethodGet)
// 定义
var response PoiCityResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"encoding/json"
"go.dtapp.net/gorequest"
"net/http"
@ -27,13 +28,13 @@ func newPoiDistrictResult(result PoiDistrictResponse, body []byte, http goreques
// PoiDistrict 基础数据 - 城市的行政区接口
// https://openapi.meituan.com/#api-0.%E5%9F%BA%E7%A1%80%E6%95%B0%E6%8D%AE-GetHttpsOpenapiMeituanComPoiDistrictCityid1
func (c *Client) PoiDistrict(cityID int) *PoiDistrictResult {
func (c *Client) PoiDistrict(ctx context.Context, cityID int) *PoiDistrictResult {
// 参数
param := gorequest.NewParams()
param.Set("cityid", cityID)
params := gorequest.NewParamsWith(param)
// 请求
request, err := c.request(apiUrl+"/poi/district", params, http.MethodGet)
request, err := c.request(ctx, apiUrl+"/poi/district", params, http.MethodGet)
// 定义
var response PoiDistrictResponse
err = json.Unmarshal(request.ResponseBody, &response)

@ -1,8 +1,11 @@
package meituan
import "go.dtapp.net/gorequest"
import (
"context"
"go.dtapp.net/gorequest"
)
func (c *Client) request(url string, params map[string]interface{}, method string) (gorequest.Response, error) {
func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, method string) (gorequest.Response, error) {
// 创建请求
client := c.client
@ -27,7 +30,7 @@ func (c *Client) request(url string, params map[string]interface{}, method strin
// 日志
if c.config.PgsqlDb != nil {
go c.log.GormMiddleware(request, Version)
go c.log.GormMiddleware(ctx, request, Version)
}
if c.config.MongoDb != nil {
go c.log.MongoMiddleware(request)

@ -1,6 +1,7 @@
package meituan
import (
"context"
"github.com/gin-gonic/gin"
"net/http"
)
@ -37,7 +38,7 @@ type ResponseServeHttpOrder struct {
// ServeHttpOrder 订单回推接口(新版)
// https://union.meituan.com/v2/apiDetail?id=22
func (c *Client) ServeHttpOrder(gCtx *gin.Context) (validateJson ResponseServeHttpOrder, err error) {
func (c *Client) ServeHttpOrder(ctx context.Context, gCtx *gin.Context) (validateJson ResponseServeHttpOrder, err error) {
// 声明接收的变量
err = gCtx.ShouldBind(&validateJson)
return

Loading…
Cancel
Save