当前位置:   article > 正文

java 获取token_java获取token

java获取token

/**
* 获取当前登录用户id
*
* @return
*/
public Long getCurrentUserIdByToken() {
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = servletRequestAttributes.getRequest();
String userName = JwtUtil.getUserNameByToken(request);

    LambdaQueryWrapper<DataUserEntity> queryWrapper = new LambdaQueryWrapper<>();
    queryWrapper.eq(DataUserEntity::getUserName, userName).eq(DataUserEntity::getIsDelete, 0);

    DataUserEntity userEntity = userDao.selectOne(queryWrapper);
    if (userEntity == null) {
        return null;
    }
    return userEntity.getId();
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号