Skip to content

关于鉴权,是什么时候存入的? #10

@fdjkpoi

Description

@fdjkpoi

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);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions