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