Skip to content

Commit

Permalink
Make user search parameters nullable and support paging.
Browse files Browse the repository at this point in the history
  • Loading branch information
hikalkan committed May 19, 2020
1 parent 73913d8 commit 5a79e7f
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Volo.Abp.Identity
{
public class UserLookupSearchInputDto : LimitedResultRequestDto, ISortedResultRequest
public class UserLookupSearchInputDto : PagedResultRequestDto, ISortedResultRequest
{
public string Sorting { get; set; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto
var users = await UserLookupServiceProvider.SearchAsync(
input.Sorting,
input.Filter,
input.MaxResultCount
input.MaxResultCount,
input.SkipCount
);

return new ListResultDto<UserData>(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,16 @@ await UserRepository.FindByNormalizedUserNameAsync(
}

public virtual async Task<List<IUserData>> SearchAsync(
string sorting,
string filter,
int maxResultCount,
string sorting = null,
string filter = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
var users = await UserRepository.GetListAsync(
sorting: sorting,
maxResultCount: maxResultCount,
skipCount: skipCount,
filter: filter,
includeDetails: false,
cancellationToken: cancellationToken
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ public virtual async Task<IUserData> FindByUserNameAsync(string userName, Cancel
}

public async Task<List<IUserData>> SearchAsync(
string sorting,
string filter,
int maxResultCount,
string sorting = null,
string filter = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
var result = await UserLookupAppService.SearchAsync(
new UserLookupSearchInputDto
{
Filter = filter,
MaxResultCount = maxResultCount
MaxResultCount = maxResultCount,
SkipCount = skipCount,
Sorting = sorting
}
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public interface IExternalUserLookupServiceProvider
Task<IUserData> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default);

Task<List<IUserData>> SearchAsync(
string sorting,
string filter,
int maxResultCount,
string sorting = null,
string filter = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ public interface IUserLookupService<TUser>
Task<TUser> FindByUserNameAsync(string userName, CancellationToken cancellationToken = default);

Task<List<IUserData>> SearchAsync(
string sorting,
string filter,
int maxResultCount,
string sorting = null,
string filter = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,37 @@ public async Task<TUser> FindByUserNameAsync(string userName, CancellationToken
return await _userRepository.FindAsync(externalUser.Id, cancellationToken: cancellationToken);
}

public async Task<List<IUserData>> SearchAsync(string sorting, string filter, int maxResultCount, CancellationToken cancellationToken = default)
public async Task<List<IUserData>> SearchAsync(
string sorting = null,
string filter = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default)
{
if (ExternalUserLookupServiceProvider != null)
{
return await ExternalUserLookupServiceProvider.SearchAsync(sorting, filter, maxResultCount, cancellationToken);
}

var localUsers = await _userRepository.SearchAsync(sorting, maxResultCount, 0, filter, cancellationToken);
return localUsers.Cast<IUserData>().ToList();
return await ExternalUserLookupServiceProvider
.SearchAsync(
sorting,
filter,
maxResultCount,
skipCount,
cancellationToken
);
}

var localUsers = await _userRepository
.SearchAsync(
sorting,
maxResultCount,
skipCount,
filter,
cancellationToken
);

return localUsers
.Cast<IUserData>()
.ToList();
}

protected abstract TUser CreateUser(IUserData externalUser);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public virtual async Task<List<TUser>> GetListAsync(IEnumerable<Guid> ids, Cance

public async Task<List<TUser>> SearchAsync(
string sorting = null,
int maxResultCount = int.MaxValue,
int maxResultCount = int.MaxValue,
int skipCount = 0,
string filter = null,
CancellationToken cancellationToken = default)
Expand Down

0 comments on commit 5a79e7f

Please sign in to comment.