parent
344a515fba
commit
508ee7c0f8
@ -0,0 +1,9 @@
|
||||
package wechatoffice
|
||||
|
||||
const (
|
||||
apiUrl = "https://api.weixin.qq.com"
|
||||
)
|
||||
|
||||
const (
|
||||
logTable = "wechatoffice"
|
||||
)
|
@ -1,27 +0,0 @@
|
||||
package wechatoffice
|
||||
|
||||
// Params 请求参数
|
||||
type Params map[string]interface{}
|
||||
|
||||
func NewParams() Params {
|
||||
p := make(Params)
|
||||
return p
|
||||
}
|
||||
|
||||
func (c *Client) NewParamsWith(params ...Params) Params {
|
||||
p := make(Params)
|
||||
for _, v := range params {
|
||||
p.SetParams(v)
|
||||
}
|
||||
return p
|
||||
}
|
||||
|
||||
func (p Params) Set(key string, value interface{}) {
|
||||
p[key] = value
|
||||
}
|
||||
|
||||
func (p Params) SetParams(params Params) {
|
||||
for key, value := range params {
|
||||
p[key] = value
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package wechatoffice
|
||||
|
||||
import "go.dtapp.net/library/utils/gorequest"
|
||||
|
||||
// 请求接口
|
||||
func (c *Client) request(url string, params map[string]interface{}, method string) (gorequest.Response, error) {
|
||||
|
||||
// 创建请求
|
||||
client := c.client
|
||||
|
||||
// 设置请求地址
|
||||
client.SetUri(url)
|
||||
|
||||
// 设置方式
|
||||
client.SetMethod(method)
|
||||
|
||||
// 设置格式
|
||||
client.SetContentTypeJson()
|
||||
|
||||
// 设置参数
|
||||
client.SetParams(params)
|
||||
|
||||
// 发起请求
|
||||
request, err := client.Request()
|
||||
if err != nil {
|
||||
return gorequest.Response{}, err
|
||||
}
|
||||
|
||||
// 日志
|
||||
if c.logStatus == true {
|
||||
go c.postgresqlLog(request)
|
||||
}
|
||||
|
||||
return request, err
|
||||
}
|
Loading…
Reference in new issue