用户上传头像实时同步缓存,无需重新登录

This commit is contained in:
RuoYi 2019-11-19 16:08:30 +08:00
parent cdc56a663e
commit 018195e47b
3 changed files with 19 additions and 0 deletions

View File

@ -9,6 +9,11 @@ import io.jsonwebtoken.Claims;
*/ */
public class Constants public class Constants
{ {
/**
* UTF-8 字符集
*/
public static final String UTF8 = "UTF-8";
/** /**
* 通用成功标识 * 通用成功标识
*/ */

View File

@ -70,6 +70,18 @@ public class TokenService
return null; return null;
} }
/**
* 设置用户身份信息
*/
public void setLoginUser(LoginUser loginUser)
{
if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken()))
{
String userKey = getTokenKey(loginUser.getToken());
redisCache.setCacheObject(userKey, loginUser);
}
}
/** /**
* 创建令牌 * 创建令牌
* *

View File

@ -98,6 +98,8 @@ public class SysProfileController extends BaseController
{ {
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
ajax.put("imgUrl", avatar); ajax.put("imgUrl", avatar);
loginUser.getUser().setAvatar(avatar);
tokenService.setLoginUser(loginUser);
return ajax; return ajax;
} }
} }