🎨优化

This commit is contained in:
coward
2024-07-12 17:18:04 +08:00
parent 9af89ee41f
commit 3e1d3d63d0
3 changed files with 7 additions and 4 deletions

View File

@@ -68,7 +68,10 @@ func (JwtComponent) GenerateToken(userId, secret string, times ...time.Time) (to
return "", nil, errors.New("生成token失败")
}
client.Redis.Set(context.Background(), fmt.Sprintf("%s:%s", constant.UserToken, userId), token, 7*time.Hour)
client.Redis.Set(context.Background(),
fmt.Sprintf("%s:%s", constant.UserToken, userId),
token,
time.Duration(expireTime.Sub(time.Now()).Abs().Seconds())*time.Second)
return
}