use of com.jun.plugin.system.vo.resp.LoginRespVO in project jun_springboot_api_service by wujun728.
the class UserServiceImpl method login.
@Override
public LoginRespVO login(SysUser vo) {
SysUser sysUser = sysUserMapper.selectOne(Wrappers.<SysUser>lambdaQuery().eq(SysUser::getUsername, vo.getUsername()));
if (null == sysUser) {
throw new BusinessException(BaseResponseCode.NOT_ACCOUNT);
}
if (sysUser.getStatus() == 2) {
throw new BusinessException(BaseResponseCode.USER_LOCK);
}
if (!PasswordUtils.matches(sysUser.getSalt(), vo.getPassword(), sysUser.getPassword())) {
throw new BusinessException(BaseResponseCode.PASSWORD_ERROR);
}
LoginRespVO respVO = new LoginRespVO();
BeanUtils.copyProperties(sysUser, respVO);
// true:允许多处登陆; false:只能单处登陆,顶掉之前登陆
if (!allowMultipleLogin) {
httpSessionService.abortUserById(sysUser.getId());
}
if (StringUtils.isNotBlank(sysUser.getDeptId())) {
SysDept sysDept = sysDeptMapper.selectById(sysUser.getDeptId());
if (sysDept != null) {
sysUser.setDeptNo(sysDept.getDeptNo());
}
}
String token = httpSessionService.createTokenAndUser(sysUser, roleService.getRoleNames(sysUser.getId()), permissionService.getPermissionsByUserId(sysUser.getId()));
respVO.setAccessToken(token);
respVO.setJwtToken(JwtUtil.sign(vo.getUsername()));
return respVO;
}
Aggregations