Browse Source

Move methods fromIdentityUserLookupAppService to IdentityUserIntegrationService

pull/17737/head
Halil İbrahim Kalkan 3 years ago
parent
commit
0e07100bcc
  1. 10
      modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Integration/IIdentityUserIntegrationService.cs
  2. 39
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs
  3. 52
      modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/Integration/IdentityUserIntegrationService.cs

10
modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Integration/IIdentityUserIntegrationService.cs

@ -1,6 +1,8 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Application.Services; using Volo.Abp.Application.Services;
using Volo.Abp.Users;
namespace Volo.Abp.Identity.Integration; namespace Volo.Abp.Identity.Integration;
@ -8,4 +10,12 @@ namespace Volo.Abp.Identity.Integration;
public interface IIdentityUserIntegrationService : IApplicationService public interface IIdentityUserIntegrationService : IApplicationService
{ {
Task<string[]> GetRoleNamesAsync(Guid id); Task<string[]> GetRoleNamesAsync(Guid id);
Task<UserData> FindByIdAsync(Guid id);
Task<UserData> FindByUserNameAsync(string userName);
Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input);
Task<long> GetCountAsync(UserLookupCountInputDto input);
} }

39
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs

@ -1,8 +1,8 @@
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity.Integration;
using Volo.Abp.Users; using Volo.Abp.Users;
namespace Volo.Abp.Identity; namespace Volo.Abp.Identity;
@ -10,54 +10,31 @@ namespace Volo.Abp.Identity;
[Authorize(IdentityPermissions.UserLookup.Default)] [Authorize(IdentityPermissions.UserLookup.Default)]
public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUserLookupAppService public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUserLookupAppService
{ {
protected IdentityUserRepositoryExternalUserLookupServiceProvider UserLookupServiceProvider { get; } protected IIdentityUserIntegrationService IdentityUserIntegrationService { get; }
public IdentityUserLookupAppService( public IdentityUserLookupAppService(
IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider) IIdentityUserIntegrationService identityUserIntegrationService)
{ {
UserLookupServiceProvider = userLookupServiceProvider; IdentityUserIntegrationService = identityUserIntegrationService;
} }
public virtual async Task<UserData> FindByIdAsync(Guid id) public virtual async Task<UserData> FindByIdAsync(Guid id)
{ {
var userData = await UserLookupServiceProvider.FindByIdAsync(id); return await IdentityUserIntegrationService.FindByIdAsync(id);
if (userData == null)
{
return null;
}
return new UserData(userData);
} }
public virtual async Task<UserData> FindByUserNameAsync(string userName) public virtual async Task<UserData> FindByUserNameAsync(string userName)
{ {
var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName); return await IdentityUserIntegrationService.FindByUserNameAsync(userName);
if (userData == null)
{
return null;
}
return new UserData(userData);
} }
public virtual async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input) public virtual async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input)
{ {
var users = await UserLookupServiceProvider.SearchAsync( return await IdentityUserIntegrationService.SearchAsync(input);
input.Sorting,
input.Filter,
input.MaxResultCount,
input.SkipCount
);
return new ListResultDto<UserData>(
users
.Select(u => new UserData(u))
.ToList()
);
} }
public virtual async Task<long> GetCountAsync(UserLookupCountInputDto input) public virtual async Task<long> GetCountAsync(UserLookupCountInputDto input)
{ {
return await UserLookupServiceProvider.GetCountAsync(input.Filter); return await IdentityUserIntegrationService.GetCountAsync(input);
} }
} }

52
modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/Integration/IdentityUserIntegrationService.cs

@ -1,19 +1,69 @@
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Users;
namespace Volo.Abp.Identity.Integration; namespace Volo.Abp.Identity.Integration;
public class IdentityUserIntegrationService : IdentityAppServiceBase, IIdentityUserIntegrationService public class IdentityUserIntegrationService : IdentityAppServiceBase, IIdentityUserIntegrationService
{ {
protected IUserRoleFinder UserRoleFinder { get; } protected IUserRoleFinder UserRoleFinder { get; }
protected IdentityUserRepositoryExternalUserLookupServiceProvider UserLookupServiceProvider { get; }
public IdentityUserIntegrationService(IUserRoleFinder userRoleFinder) public IdentityUserIntegrationService(
IUserRoleFinder userRoleFinder,
IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider)
{ {
UserRoleFinder = userRoleFinder; UserRoleFinder = userRoleFinder;
UserLookupServiceProvider = userLookupServiceProvider;
} }
public virtual async Task<string[]> GetRoleNamesAsync(Guid id) public virtual async Task<string[]> GetRoleNamesAsync(Guid id)
{ {
return await UserRoleFinder.GetRoleNamesAsync(id); return await UserRoleFinder.GetRoleNamesAsync(id);
} }
public virtual async Task<UserData> FindByIdAsync(Guid id)
{
var userData = await UserLookupServiceProvider.FindByIdAsync(id);
if (userData == null)
{
return null;
}
return new UserData(userData);
}
public virtual async Task<UserData> FindByUserNameAsync(string userName)
{
var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName);
if (userData == null)
{
return null;
}
return new UserData(userData);
}
public virtual async Task<ListResultDto<UserData>> SearchAsync(UserLookupSearchInputDto input)
{
var users = await UserLookupServiceProvider.SearchAsync(
input.Sorting,
input.Filter,
input.MaxResultCount,
input.SkipCount
);
return new ListResultDto<UserData>(
users
.Select(u => new UserData(u))
.ToList()
);
}
public virtual async Task<long> GetCountAsync(UserLookupCountInputDto input)
{
return await UserLookupServiceProvider.GetCountAsync(input.Filter);
}
} }

Loading…
Cancel
Save