- yilianyun printer added
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
|
||||
"git.rosy.net.cn/baseapi/platformapi/weimobapi"
|
||||
"git.rosy.net.cn/baseapi/platformapi/yilianyunapi"
|
||||
"git.rosy.net.cn/baseapi/utils"
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
|
||||
@@ -17,11 +18,12 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
weixinTokenExpires = 7200 * time.Second
|
||||
dingdingTokenExpires = 7200 * time.Second
|
||||
elmTokenExpires = 20 * 24 * 3600 * time.Second
|
||||
weimobTokenExpires = 7200 * time.Second
|
||||
maxRefreshGap = 5 * 60 * time.Second
|
||||
weixinTokenExpires = 7200 * time.Second
|
||||
dingdingTokenExpires = 7200 * time.Second
|
||||
elmTokenExpires = 20 * 24 * 3600 * time.Second
|
||||
weimobTokenExpires = 7200 * time.Second
|
||||
maxRefreshGap = 5 * 60 * time.Second
|
||||
yilianyunTokenExpires = 30 * 24 * 3600 * time.Second
|
||||
)
|
||||
|
||||
type ElmTokenForCompatible struct {
|
||||
@@ -192,3 +194,23 @@ func SaveWeimobToken(token *weimobapi.TokenInfo) (err error) {
|
||||
}
|
||||
return dao.CreateOrUpdate(db, config)
|
||||
}
|
||||
|
||||
func RefreshYilianyunToken() error {
|
||||
return RefreshConfig("yilianyun", yilianyunTokenExpires, func() (string, string) {
|
||||
globals.SugarLogger.Debugf("RefreshYilianyunToken RunMode:%s", beego.BConfig.RunMode)
|
||||
if true { //beego.BConfig.RunMode == "prod" {
|
||||
if tokenInfo, err := api.YilianyunAPI.RetrieveToken(); err == nil {
|
||||
return string(utils.MustMarshal(tokenInfo)), ""
|
||||
} else {
|
||||
globals.SugarLogger.Errorf("RefreshYilianyunToken RefreshToken failed with error:%v", err)
|
||||
}
|
||||
}
|
||||
return "", ""
|
||||
}, func(value string) {
|
||||
var tokenInfo *yilianyunapi.TokenInfo
|
||||
err := utils.UnmarshalUseNumber([]byte(value), &tokenInfo)
|
||||
if err == nil {
|
||||
api.YilianyunAPI.SetToken(tokenInfo.AccessToken)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user