Modified the API parameter of get all users
This commit is contained in:
@@ -448,12 +448,14 @@ public class UserDao {
|
||||
return authService.validateNewUserToken(token);
|
||||
}
|
||||
|
||||
public List<UserResponseBean> getAllUsers(UserEntity user, Long roleId) {
|
||||
public List<UserResponseBean> getAllUsers(UserEntity user, List<Long> roleIds) {
|
||||
List<UserEntity> users;
|
||||
if (roleId != null) {
|
||||
log.info("Fetching users by role ID: {}", roleId);
|
||||
RoleEntity roleEntity=roleService.validateRole(roleId);
|
||||
users = userRepository.findByRoleEntityIdAndHubId(roleEntity.getId(), user.getHub().getId());
|
||||
if (roleIds != null) {
|
||||
log.info("Fetching users by role ID: {}", roleIds);
|
||||
List<RoleEntity> roleEntities = roleIds.stream()
|
||||
.map(roleService::validateRole) // Assuming `validateRole` takes an ID and returns a RoleEntity
|
||||
.collect(Collectors.toList());
|
||||
users = userRepository.findByRoleEntityIdInAndHubId(roleIds, user.getHub().getId());
|
||||
} else {
|
||||
log.info("Fetching all users");
|
||||
users = userRepository.findByHubId(user.getHub().getId());
|
||||
@@ -462,7 +464,7 @@ public class UserDao {
|
||||
.map(this::convertUserEntityToUserResponse)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
log.info("Total users found with role ID {}: {}", roleId, userResponseBeans.size());
|
||||
log.info("Total users found with role ID {}: {}", roleIds, userResponseBeans.size());
|
||||
return userResponseBeans;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user