| | |
| | | import cn.hutool.http.useragent.UserAgentUtil; |
| | | import com.ruoyi.common.constant.Constants; |
| | | import com.ruoyi.common.core.domain.model.LoginUser; |
| | | import com.ruoyi.common.core.redis.RedisCache; |
| | | import com.ruoyi.common.utils.RedisUtils; |
| | | import com.ruoyi.common.utils.ServletUtils; |
| | | import com.ruoyi.common.utils.StringUtils; |
| | | import com.ruoyi.common.utils.ip.AddressUtils; |
| | |
| | | private static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L; |
| | | |
| | | @Autowired |
| | | private RedisCache redisCache; |
| | | |
| | | @Autowired |
| | | private TokenProperties tokenProperties; |
| | | |
| | | /** |
| | |
| | | // 解析对应的权限以及用户信息 |
| | | String uuid = (String) claims.get(Constants.LOGIN_USER_KEY); |
| | | String userKey = getTokenKey(uuid); |
| | | LoginUser user = redisCache.getCacheObject(userKey); |
| | | LoginUser user = RedisUtils.getCacheObject(userKey); |
| | | return user; |
| | | } catch (Exception e) { |
| | | |
| | |
| | | public void delLoginUser(String token) { |
| | | if (StringUtils.isNotEmpty(token)) { |
| | | String userKey = getTokenKey(token); |
| | | redisCache.deleteObject(userKey); |
| | | RedisUtils.deleteObject(userKey); |
| | | } |
| | | } |
| | | |
| | |
| | | loginUser.setExpireTime(loginUser.getLoginTime() + tokenProperties.getExpireTime() * MILLIS_MINUTE); |
| | | // 根据uuid将loginUser缓存 |
| | | String userKey = getTokenKey(loginUser.getToken()); |
| | | redisCache.setCacheObject(userKey, loginUser, tokenProperties.getExpireTime(), TimeUnit.MINUTES); |
| | | RedisUtils.setCacheObject(userKey, loginUser, tokenProperties.getExpireTime(), TimeUnit.MINUTES); |
| | | } |
| | | |
| | | /** |