赞
踩
/**
* 获取当前登录用户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();
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。