代码拉取完成,页面将自动刷新
package api
import (
"reflect"
)
import (
"gitee.com/changeden/jd-union-go-sdk/common"
"gitee.com/changeden/jd-union-go-sdk/method"
"gitee.com/changeden/jd-union-go-sdk/pkg"
)
// https://union.jd.com/openplatform/api/v2
type api struct {
// 组装Api集合
method.ApiGoodsMethods
method.ApiEffectMethods
method.ApiManageMethods
method.ApiPromotionMethods
method.ApiSellingMethods
method.ApiToolMethods
config *apiConfig
// 方法插件实例数组
_apiMethodPlugins []pkg.ApiMethodPlugin
}
func newApi(config *apiConfig) *api {
inst := &api{
config: config,
}
methodPlugins := getApiMethodPlugin(inst)
inst._apiMethodPlugins = methodPlugins
return inst
}
func getApiMethodPlugin(v *api) []pkg.ApiMethodPlugin {
methodPlugins := make([]pkg.ApiMethodPlugin, 0)
apiValue := reflect.ValueOf(v).Elem()
requestFunc := v.request
var p pkg.ApiMethodPlugin
var canConv bool
for i := 0; i < apiValue.NumField(); i++ {
f := apiValue.Field(i)
if !(f.IsValid() && f.CanInterface()) {
continue
}
if p, canConv = f.Interface().(pkg.ApiMethodPlugin); !canConv {
continue
}
r := f.FieldByName(common.ApiMethodPluginBaseRequestKey)
if !(r.IsValid() && r.CanSet()) {
continue
}
r.Set(reflect.ValueOf(requestFunc))
methodPlugins = append(methodPlugins, p)
}
return methodPlugins
}
func (a *api) request(method *pkg.ApiMethod, params pkg.ApiRequestBody, accessToken *string) (*pkg.ApiResponseDTO, error) {
return NewApiBody(a.config).
SetMethod(method.Method).
SetParamJson(params).
SetAccessToken(accessToken).
Request(method.ResponseWrapKey)
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。