- 重要修改相关的函数新增trackInfo参数,追踪修改人.接口类型改变
This commit is contained in:
@@ -143,7 +143,7 @@ func New(token, appKey, appSecret string, config ...*platformapi.APIConfig) *API
|
||||
}
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
func (a *API) AccessAPI2(apiStr string, jdParams map[string]interface{}, traceInfo string) (retVal map[string]interface{}, err error) {
|
||||
params := make(map[string]interface{})
|
||||
params["v"] = "1.0"
|
||||
params["format"] = "json"
|
||||
@@ -182,6 +182,9 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
|
||||
request.Header.Set("charset", "UTF-8")
|
||||
request.Header.Set("Content-Type", "application/x-www-form-urlencoded")
|
||||
}
|
||||
if traceInfo != "" {
|
||||
request.Header.Set(platformapi.KeyTrackInfo, traceInfo)
|
||||
}
|
||||
// request.Close = true //todo 为了性能考虑还是不要关闭
|
||||
return request
|
||||
},
|
||||
@@ -208,6 +211,10 @@ func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal
|
||||
return retVal, platformapi.RebuildError(err, jdParams, watchKeys)
|
||||
}
|
||||
|
||||
func (a *API) AccessAPI(apiStr string, jdParams map[string]interface{}) (retVal map[string]interface{}, err error) {
|
||||
return a.AccessAPI2(apiStr, jdParams, "")
|
||||
}
|
||||
|
||||
func genNoPageResultParser(codeKey, msgKey, resultKey, okCode string) func(data map[string]interface{}) (interface{}, error) {
|
||||
return func(data map[string]interface{}) (innerData interface{}, err error) {
|
||||
rawInnerCode, ok := data[codeKey]
|
||||
@@ -236,11 +243,11 @@ func formatErrorMsg(msg interface{}) (strMsg string) {
|
||||
return strMsg
|
||||
}
|
||||
|
||||
func (a *API) AccessAPINoPage(apiStr string, jdParams map[string]interface{}, keyToRemove, keyToKeep []string, resultParser func(data map[string]interface{}) (interface{}, error)) (interface{}, error) {
|
||||
func (a *API) AccessAPINoPage2(apiStr string, jdParams map[string]interface{}, keyToRemove, keyToKeep []string, resultParser func(data map[string]interface{}) (interface{}, error), traceInfo string) (interface{}, error) {
|
||||
if resultParser == nil {
|
||||
resultParser = genNoPageResultParser("code", "msg", "result", "0")
|
||||
}
|
||||
jsonResult, err := a.AccessAPI(apiStr, jdParams)
|
||||
jsonResult, err := a.AccessAPI2(apiStr, jdParams, traceInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -257,6 +264,10 @@ func (a *API) AccessAPINoPage(apiStr string, jdParams map[string]interface{}, ke
|
||||
return result, err
|
||||
}
|
||||
|
||||
func (a *API) AccessAPINoPage(apiStr string, jdParams map[string]interface{}, keyToRemove, keyToKeep []string, resultParser func(data map[string]interface{}) (interface{}, error)) (interface{}, error) {
|
||||
return a.AccessAPINoPage2(apiStr, jdParams, keyToRemove, keyToKeep, resultParser, "")
|
||||
}
|
||||
|
||||
func normalHavePageResultParser(data map[string]interface{}, totalCount int) ([]interface{}, int, error) {
|
||||
var result map[string]interface{}
|
||||
var retVal []interface{}
|
||||
|
||||
Reference in New Issue
Block a user