mirror of
https://github.com/chillzhuang/blade-tool
synced 2024-12-12 12:19:27 +08:00
⚡ 代码优化
This commit is contained in:
parent
c5f6342f9e
commit
474db1b5ec
@ -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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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));
|
||||||
|
Loading…
Reference in New Issue
Block a user