-
Notifications
You must be signed in to change notification settings - Fork 415
Open
Description
CurrentUserMethodArgumentResolver 这个类,没看到这个值怎么存入的,可以讲解下把。
@OverRide
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
//取出鉴权时存入的登录用户Id
Long currentUserId = (Long) webRequest.getAttribute(Constants.CURRENT_USER_ID, RequestAttributes.SCOPE_REQUEST);
if (currentUserId != null) {
//从数据库中查询并返回
return userRepository.findOne(currentUserId);
}
throw new MissingServletRequestPartException(Constants.CURRENT_USER_ID);
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels