- 将BindPrinterResult.ExpiresIn改为ExpiresAt

This commit is contained in:
gazebo
2019-07-11 11:20:05 +08:00
parent d11e3d84cd
commit 4817d5c1c2
3 changed files with 6 additions and 6 deletions

View File

@@ -139,7 +139,7 @@ func RebindAllPrinters(ctx *jxcontext.Context, isForce, isAsync bool) (hint stri
for _, v := range storeList { for _, v := range storeList {
var bindResult partner.BindPrinterResult var bindResult partner.BindPrinterResult
if err = utils.UnmarshalUseNumber([]byte(v.PrinterBindInfo), &bindResult); err == nil { if err = utils.UnmarshalUseNumber([]byte(v.PrinterBindInfo), &bindResult); err == nil {
if isForce || now.Sub(utils.Timestamp2Time(bindResult.ExpiresIn)) > -24*time.Hour { if isForce || now.Sub(utils.Timestamp2Time(bindResult.ExpiresAt)) > -48*time.Hour {
needRebindList = append(needRebindList, v) needRebindList = append(needRebindList, v)
bindResultMap[v.ID] = &bindResult bindResultMap[v.ID] = &bindResult
} }

View File

@@ -8,10 +8,10 @@ import (
) )
type BindPrinterResult struct { type BindPrinterResult struct {
PrinterSN string PrinterSN string `json:"printerSN"`
PrinterKey string PrinterKey string `json:"printerKey"`
PrinterKey2 string PrinterKey2 string `json:"printerKey2"`
ExpiresIn int64 `json:"expires_in"` ExpiresAt int64 `json:"expiresAt"`
} }
type IPrinterHandler interface { type IPrinterHandler interface {

View File

@@ -172,7 +172,7 @@ func yilianyunToken2BindResult(tokenInfo *yilianyunapi.TokenInfo) (bindResult *p
PrinterSN: tokenInfo.MachineCode, PrinterSN: tokenInfo.MachineCode,
PrinterKey: tokenInfo.AccessToken, PrinterKey: tokenInfo.AccessToken,
PrinterKey2: tokenInfo.RefreshToken, PrinterKey2: tokenInfo.RefreshToken,
ExpiresIn: tokenInfo.ExpiresIn, ExpiresAt: time.Now().Add(time.Duration(tokenInfo.ExpiresIn)).Unix(),
} }
} }