From 0e07100bcc65792f78d8b3f5b0f6fa88f2ed25de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 26 Sep 2023 10:12:52 +0300 Subject: [PATCH] Move methods fromIdentityUserLookupAppService to IdentityUserIntegrationService --- .../IIdentityUserIntegrationService.cs | 10 ++++ .../Identity/IdentityUserLookupAppService.cs | 39 +++----------- .../IdentityUserIntegrationService.cs | 52 ++++++++++++++++++- 3 files changed, 69 insertions(+), 32 deletions(-) diff --git a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Integration/IIdentityUserIntegrationService.cs b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Integration/IIdentityUserIntegrationService.cs index e690b8bd0a..815c1c48c9 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Integration/IIdentityUserIntegrationService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/Integration/IIdentityUserIntegrationService.cs @@ -1,6 +1,8 @@ using System; using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; using Volo.Abp.Application.Services; +using Volo.Abp.Users; namespace Volo.Abp.Identity.Integration; @@ -8,4 +10,12 @@ namespace Volo.Abp.Identity.Integration; public interface IIdentityUserIntegrationService : IApplicationService { Task GetRoleNamesAsync(Guid id); + + Task FindByIdAsync(Guid id); + + Task FindByUserNameAsync(string userName); + + Task> SearchAsync(UserLookupSearchInputDto input); + + Task GetCountAsync(UserLookupCountInputDto input); } \ No newline at end of file diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs index 4695517810..d8baff07ad 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/IdentityUserLookupAppService.cs @@ -1,8 +1,8 @@ using System; -using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Volo.Abp.Application.Dtos; +using Volo.Abp.Identity.Integration; using Volo.Abp.Users; namespace Volo.Abp.Identity; @@ -10,54 +10,31 @@ namespace Volo.Abp.Identity; [Authorize(IdentityPermissions.UserLookup.Default)] public class IdentityUserLookupAppService : IdentityAppServiceBase, IIdentityUserLookupAppService { - protected IdentityUserRepositoryExternalUserLookupServiceProvider UserLookupServiceProvider { get; } + protected IIdentityUserIntegrationService IdentityUserIntegrationService { get; } public IdentityUserLookupAppService( - IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider) + IIdentityUserIntegrationService identityUserIntegrationService) { - UserLookupServiceProvider = userLookupServiceProvider; + IdentityUserIntegrationService = identityUserIntegrationService; } public virtual async Task FindByIdAsync(Guid id) { - var userData = await UserLookupServiceProvider.FindByIdAsync(id); - if (userData == null) - { - return null; - } - - return new UserData(userData); + return await IdentityUserIntegrationService.FindByIdAsync(id); } public virtual async Task FindByUserNameAsync(string userName) { - var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName); - if (userData == null) - { - return null; - } - - return new UserData(userData); + return await IdentityUserIntegrationService.FindByUserNameAsync(userName); } public virtual async Task> SearchAsync(UserLookupSearchInputDto input) { - var users = await UserLookupServiceProvider.SearchAsync( - input.Sorting, - input.Filter, - input.MaxResultCount, - input.SkipCount - ); - - return new ListResultDto( - users - .Select(u => new UserData(u)) - .ToList() - ); + return await IdentityUserIntegrationService.SearchAsync(input); } public virtual async Task GetCountAsync(UserLookupCountInputDto input) { - return await UserLookupServiceProvider.GetCountAsync(input.Filter); + return await IdentityUserIntegrationService.GetCountAsync(input); } } diff --git a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/Integration/IdentityUserIntegrationService.cs b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/Integration/IdentityUserIntegrationService.cs index b18f58f3a5..37446ce1f3 100644 --- a/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/Integration/IdentityUserIntegrationService.cs +++ b/modules/identity/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/Integration/IdentityUserIntegrationService.cs @@ -1,19 +1,69 @@ using System; +using System.Linq; using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Users; namespace Volo.Abp.Identity.Integration; public class IdentityUserIntegrationService : IdentityAppServiceBase, IIdentityUserIntegrationService { protected IUserRoleFinder UserRoleFinder { get; } + protected IdentityUserRepositoryExternalUserLookupServiceProvider UserLookupServiceProvider { get; } - public IdentityUserIntegrationService(IUserRoleFinder userRoleFinder) + public IdentityUserIntegrationService( + IUserRoleFinder userRoleFinder, + IdentityUserRepositoryExternalUserLookupServiceProvider userLookupServiceProvider) { UserRoleFinder = userRoleFinder; + UserLookupServiceProvider = userLookupServiceProvider; } public virtual async Task GetRoleNamesAsync(Guid id) { return await UserRoleFinder.GetRoleNamesAsync(id); } + + public virtual async Task FindByIdAsync(Guid id) + { + var userData = await UserLookupServiceProvider.FindByIdAsync(id); + if (userData == null) + { + return null; + } + + return new UserData(userData); + } + + public virtual async Task FindByUserNameAsync(string userName) + { + var userData = await UserLookupServiceProvider.FindByUserNameAsync(userName); + if (userData == null) + { + return null; + } + + return new UserData(userData); + } + + public virtual async Task> SearchAsync(UserLookupSearchInputDto input) + { + var users = await UserLookupServiceProvider.SearchAsync( + input.Sorting, + input.Filter, + input.MaxResultCount, + input.SkipCount + ); + + return new ListResultDto( + users + .Select(u => new UserData(u)) + .ToList() + ); + } + + public virtual async Task GetCountAsync(UserLookupCountInputDto input) + { + return await UserLookupServiceProvider.GetCountAsync(input.Filter); + } }