+ apimanager
This commit is contained in:
@@ -22,18 +22,12 @@ import (
|
||||
"git.rosy.net.cn/baseapi/platformapi/zhongwuapi"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache"
|
||||
"git.rosy.net.cn/jx-callback/business/jxutils/cache/redis"
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
|
||||
"github.com/astaxie/beego"
|
||||
"github.com/qiniu/api.v7/auth/qbox"
|
||||
)
|
||||
|
||||
type APIManager struct {
|
||||
}
|
||||
|
||||
var (
|
||||
curAPIManager *APIManager
|
||||
|
||||
JdAPI *jdapi.API
|
||||
JdPageAPI *jdapi.API
|
||||
ElmAPI *elmapi.API
|
||||
@@ -65,22 +59,12 @@ var (
|
||||
Cacher cache.ICacher
|
||||
)
|
||||
|
||||
func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
||||
if vendorID == model.VendorIDJD {
|
||||
pfAPI = JdAPI
|
||||
}
|
||||
return pfAPI
|
||||
}
|
||||
|
||||
func init() {
|
||||
Init() // 这里必须要调用
|
||||
}
|
||||
|
||||
// 这样写的原因是在测试时,可以重新读取配置文件
|
||||
func Init() {
|
||||
curAPIManager = &APIManager{}
|
||||
// partner.InitAPIManager(curAPIManager)
|
||||
|
||||
if !beego.AppConfig.DefaultBool("disableJd", false) {
|
||||
JdAPI = jdapi.New(beego.AppConfig.String("jdToken"), beego.AppConfig.String("jdAppKey"), beego.AppConfig.String("jdSecret"))
|
||||
cookieValue := beego.AppConfig.DefaultString("jdStorePageCookie", "")
|
||||
|
||||
31
globals/api/apimanager/apimanager.go
Normal file
31
globals/api/apimanager/apimanager.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package apimanager
|
||||
|
||||
import (
|
||||
"git.rosy.net.cn/jx-callback/business/model"
|
||||
"git.rosy.net.cn/jx-callback/business/partner"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
)
|
||||
|
||||
type APIManager struct {
|
||||
}
|
||||
|
||||
var (
|
||||
curAPIManager *APIManager
|
||||
)
|
||||
|
||||
func init() {
|
||||
curAPIManager = &APIManager{}
|
||||
partner.InitAPIManager(curAPIManager)
|
||||
}
|
||||
|
||||
func (a *APIManager) GetAPI(vendorID int, name string) (pfAPI interface{}) {
|
||||
switch vendorID {
|
||||
case model.VendorIDJD:
|
||||
pfAPI = api.JdAPI
|
||||
case model.VendorIDMTWM:
|
||||
pfAPI = api.MtwmAPI
|
||||
case model.VendorIDEBAI:
|
||||
pfAPI = api.EbaiAPI
|
||||
}
|
||||
return pfAPI
|
||||
}
|
||||
Reference in New Issue
Block a user