|
|
|
@ -47,6 +47,8 @@ public class UserDetailsServiceImpl implements UserDetailsService { |
|
|
|
|
private AuthEmployeeRoleDao userRoleMapper; |
|
|
|
|
@Autowired |
|
|
|
|
private HrauthFeignService hrauthFeignService; |
|
|
|
|
@Autowired |
|
|
|
|
private UserLoginDao userLoginDao; |
|
|
|
|
|
|
|
|
|
/*** |
|
|
|
|
* 根据账号获取用户信息 |
|
|
|
@ -57,13 +59,20 @@ public class UserDetailsServiceImpl implements UserDetailsService { |
|
|
|
|
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { |
|
|
|
|
// 从数据库中取出用户信息
|
|
|
|
|
List<UserEntity> userList = userMapper.selectList(new QueryWrapper<UserEntity>().eq("phone_account", username)); |
|
|
|
|
List<UserEntity> userList2 = userMapper.selectList(new QueryWrapper<UserEntity>().eq("account", username)); |
|
|
|
|
UserEntity user; |
|
|
|
|
String name = null; |
|
|
|
|
// 判断用户是否存在
|
|
|
|
|
if (!CollectionUtils.isEmpty(userList)) { |
|
|
|
|
user = userList.get(0); |
|
|
|
|
name = userLoginDao.getNameByUserId(userList.get(0).getId()); |
|
|
|
|
} else if(!CollectionUtils.isEmpty(userList2)){ |
|
|
|
|
user = userList2.get(0); |
|
|
|
|
name = userLoginDao.getNameByUserId(userList2.get(0).getId()); |
|
|
|
|
} else { |
|
|
|
|
throw new UsernameNotFoundException("用户名不存在或已禁用!"); |
|
|
|
|
} |
|
|
|
|
user.setAccount(name); |
|
|
|
|
// 返回UserDetails实现类
|
|
|
|
|
return new SecurityUser(user, getUserRoles(user.getId().intValue())); |
|
|
|
|
} |
|
|
|
|