1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 |
- package thirdparty
- import (
- "gd_management/common.in/httpClient"
- "gd_management/common.in/utils"
- "fmt"
- "go.uber.org/zap"
- )
- var (
- edHost = "https://api.edaishen.net"
- edApiPrefix = "oapi/store/oindex.php"
- )
- func edFullUrl() string {
- return fmt.Sprintf("%s/%s", edHost, edApiPrefix)
- }
- func EdSetHost(host string) {
- edHost = host
- }
- func EdPost(host string, route string, token string, data []byte) (result []byte, err error) {
- url := fmt.Sprintf("%s?route=%s&access_token=%s", host, route, token)
- defer func() {
- if l == nil {
- return
- }
- l.Info("thirdparty",
- zap.String("api", url),
- zap.String("request", utils.MarshalJsonString(data)),
- zap.String("response", string(result)))
- }()
- result, err = httpClient.HttpPostBytes(url, data)
- return result, err
- }
- func EdGet(host string, data map[string]string) (result []byte, err error) {
- defer func() {
- l.Info("thirdparty",
- zap.String("api", host),
- zap.String("request", utils.MarshalJsonString(data)),
- zap.String("response", string(result)))
- }()
- result, err = httpClient.HttpGet(host, data)
- return result, err
- }
|