代码优化

This commit is contained in:
smallchill 2018-12-24 13:07:47 +08:00
parent c5f6342f9e
commit 474db1b5ec
2 changed files with 2 additions and 5 deletions

View File

@ -24,8 +24,6 @@ import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver; import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer; import org.springframework.web.method.support.ModelAndViewContainer;
import javax.servlet.http.HttpServletRequest;
/** /**
* Token转化BladeUser * Token转化BladeUser
*/ */
@ -56,8 +54,7 @@ public class TokenArgumentResolver implements HandlerMethodArgumentResolver {
ModelAndViewContainer modelAndViewContainer, ModelAndViewContainer modelAndViewContainer,
NativeWebRequest nativeWebRequest, NativeWebRequest nativeWebRequest,
WebDataBinderFactory webDataBinderFactory) { WebDataBinderFactory webDataBinderFactory) {
HttpServletRequest request = nativeWebRequest.getNativeRequest(HttpServletRequest.class); return SecureUtil.getUser();
return SecureUtil.getUser(request);
} }
} }

View File

@ -75,7 +75,7 @@ public class SecureUtil {
public static BladeUser getUser(HttpServletRequest request) { public static BladeUser getUser(HttpServletRequest request) {
Claims claims = getClaims(request); Claims claims = getClaims(request);
if (claims == null) { if (claims == null) {
return new BladeUser(); return null;
} }
Integer userId = Func.toInt(claims.get(SecureUtil.userId)); Integer userId = Func.toInt(claims.get(SecureUtil.userId));
String roleId = Func.toStr(claims.get(SecureUtil.roleId)); String roleId = Func.toStr(claims.get(SecureUtil.roleId));