- 添加Struct2MapByJson
- 去掉将全局structs.DefaultTagName设置为"json"
This commit is contained in:
@@ -6,8 +6,6 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -82,7 +80,7 @@ func (a *API) GetOrderCallbackMsg(data []byte) (msg *CallbackMsg, callbackRespon
|
||||
return nil, FailedResponse
|
||||
}
|
||||
|
||||
mapData := structs.Map(msg)
|
||||
mapData := utils.Struct2MapByJson(msg)
|
||||
callbackResponse = a.CheckCallbackValidation(mapData)
|
||||
return msg, callbackResponse
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package dadaapi
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"github.com/fatih/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -89,7 +88,7 @@ func map2CreateOrderResponse(mapData map[string]interface{}) *CreateOrderRespons
|
||||
}
|
||||
|
||||
func (a *API) operateOrder(action string, orderInfo *OperateOrderRequiredParams, addParams map[string]interface{}) (retVal *CreateOrderResponse, err error) {
|
||||
params := structs.Map(orderInfo)
|
||||
params := utils.Struct2MapByJson(orderInfo)
|
||||
params["callback"] = a.callbackURL
|
||||
allParams := utils.MergeMaps(params, addParams)
|
||||
result, err := a.AccessAPI(action, allParams)
|
||||
|
||||
@@ -13,7 +13,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"github.com/fatih/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -65,7 +64,7 @@ func (a *API) PackCallbackResult(result string) (response *CallbackResponse) {
|
||||
Timestamp: utils.Int64ToStr(time.Now().Unix()),
|
||||
Nonce: utils.GetUUID(),
|
||||
}
|
||||
response.MsgSignature = a.calculateCallbackSign(structs.Map(response))
|
||||
response.MsgSignature = a.calculateCallbackSign(utils.Struct2MapByJson(response))
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ import (
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"github.com/fatih/structs"
|
||||
)
|
||||
|
||||
// https://open.shop.ele.me/openapi/documents/callback
|
||||
@@ -187,7 +186,7 @@ func (a *API) GetCallbackMsg(data []byte) (msg *CallbackMsg, callbackResponse *C
|
||||
return nil, callbackResponse
|
||||
}
|
||||
|
||||
mapData := structs.Map(msg)
|
||||
mapData := utils.Struct2MapByJson(msg)
|
||||
callbackResponse = a.CheckCallbackValidation(mapData)
|
||||
return msg, callbackResponse
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/fatih/structs"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
)
|
||||
@@ -244,7 +242,7 @@ func (a *API) result2OrderResponse(result *ResponseResult) (order *OrderResponse
|
||||
}
|
||||
|
||||
func (a *API) CreateOrderByShop(basicParams *CreateOrderByShopParam, addParams map[string]interface{}) (order *OrderResponse, err error) {
|
||||
params := structs.Map(basicParams)
|
||||
params := utils.Struct2MapByJson(basicParams)
|
||||
params["goods_value"] = strconv.FormatFloat(basicParams.GoodsValue, 'f', 2, 64)
|
||||
params["goods_weight"] = strconv.FormatFloat(basicParams.GoodsWeight, 'f', 2, 64)
|
||||
allParams := utils.MergeMaps(params, addParams)
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
"git.rosy.net.cn/baseapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"github.com/fatih/structs"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -79,10 +78,6 @@ var (
|
||||
ErrStrCallbackSignatureIsWrong = "wrong signature"
|
||||
)
|
||||
|
||||
func init() {
|
||||
structs.DefaultTagName = "json"
|
||||
}
|
||||
|
||||
func getClonedData(requestURL *url.URL, r *bytes.Buffer) string {
|
||||
if strings.Index(requestURL.String(), "uploadImg") >= 0 {
|
||||
return "binary content"
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package weimobapi
|
||||
|
||||
import (
|
||||
"github.com/fatih/structs"
|
||||
)
|
||||
import "git.rosy.net.cn/baseapi/utils"
|
||||
|
||||
const (
|
||||
OrderStatusWait4Pay = 0 // 待支付
|
||||
@@ -52,7 +50,7 @@ func (a *API) CancelOrder(orderNo int64, specificCancelReason string) (err error
|
||||
}
|
||||
|
||||
func (a *API) DeliveryOrder(orderDeliveryInfo *DeliveryOrder) (err error) {
|
||||
apiParams := structs.Map(orderDeliveryInfo)
|
||||
apiParams := utils.Struct2MapByJson(orderDeliveryInfo)
|
||||
// baseapi.SugarLogger.Debug(utils.Format4Output(apiParams, false))
|
||||
_, err = a.AccessAPI("order/deliveryOrder", apiParams)
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user