提交 df8944be 作者: han

bug

上级 2e216e24
...@@ -43,6 +43,7 @@ public class AuthHandler { ...@@ -43,6 +43,7 @@ public class AuthHandler {
String token = JwtUtil.createJwt(map); String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).openId(userAccountVO.getOpenId()).userAccountId(userAccountVO.getId()).uid(userAccountVO.getId() + "") LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).openId(userAccountVO.getOpenId()).userAccountId(userAccountVO.getId()).uid(userAccountVO.getId() + "")
.userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).portType(UserTypeEnums.APP.getType()).build(); .userName(userAccountVO.getUserName()).nickName(userAccountVO.getNickName()).phoneNum(userAccountVO.getPhoneNum()).portType(UserTypeEnums.APP.getType()).build();
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
stringRedisTemplate.opsForValue().set( stringRedisTemplate.opsForValue().set(
token, new Gson().toJson(loginSuccessDTO), token, new Gson().toJson(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS); JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
...@@ -58,6 +59,7 @@ public class AuthHandler { ...@@ -58,6 +59,7 @@ public class AuthHandler {
String token = JwtUtil.createJwt(map); String token = JwtUtil.createJwt(map);
LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).userAccountId(userAccountVO.getId()) LoginSuccessDTO loginSuccessDTO = LoginSuccessDTO.builder().token(token).userAccountId(userAccountVO.getId())
.phoneNum(userAccountVO.getPhoneNum()).portType(UserTypeEnums.APP.getType()).build(); .phoneNum(userAccountVO.getPhoneNum()).portType(UserTypeEnums.APP.getType()).build();
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
stringRedisTemplate.opsForValue().set( stringRedisTemplate.opsForValue().set(
token, new Gson().toJson(loginSuccessDTO), token, new Gson().toJson(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS); JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
...@@ -80,6 +82,7 @@ public class AuthHandler { ...@@ -80,6 +82,7 @@ public class AuthHandler {
.userName(user.getUserName()).nickName(user.getUserName()).phoneNum(user.getPhoneNum()).portType(UserTypeEnums.PC.getType()) .userName(user.getUserName()).nickName(user.getUserName()).phoneNum(user.getPhoneNum()).portType(UserTypeEnums.PC.getType())
.companyInfoVO(companyInfoVO == null ? null : companyInfoVO) .companyInfoVO(companyInfoVO == null ? null : companyInfoVO)
.roleInfo(roleInfoDO.buildRoleInfoDTO()).build(); .roleInfo(roleInfoDO.buildRoleInfoDTO()).build();
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
stringRedisTemplate.opsForValue().set( stringRedisTemplate.opsForValue().set(
token, new Gson().toJson(loginSuccessDTO), token, new Gson().toJson(loginSuccessDTO),
JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS); JwtConstant.EXPIRATION, TimeUnit.MILLISECONDS);
......
...@@ -43,6 +43,7 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor { ...@@ -43,6 +43,7 @@ public class TokenCheckHandleInterceptor implements HandlerInterceptor {
exceptionProcess(response); exceptionProcess(response);
return false; return false;
} }
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
String tokenJson = stringRedisTemplate.opsForValue().get(token); String tokenJson = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(tokenJson)) { if (StringUtils.isBlank(tokenJson)) {
exceptionProcess(response); exceptionProcess(response);
......
...@@ -12,6 +12,7 @@ import io.jsonwebtoken.Claims; ...@@ -12,6 +12,7 @@ import io.jsonwebtoken.Claims;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.serializer.RedisSerializer;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
...@@ -54,6 +55,7 @@ public abstract class BaseController { ...@@ -54,6 +55,7 @@ public abstract class BaseController {
if (StringUtils.isBlank(token)){ if (StringUtils.isBlank(token)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR); throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
} }
stringRedisTemplate.setValueSerializer(RedisSerializer.json());
String json = stringRedisTemplate.opsForValue().get(token); String json = stringRedisTemplate.opsForValue().get(token);
if (StringUtils.isBlank(json)){ if (StringUtils.isBlank(json)){
throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR); throw new BizException(ResultEnum.LOGIN_ACCOUNT_STATUS_ERROR);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论