From 11b74bd75da6b8781130c5a0c22ea302b64bdfc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Tue, 6 Mar 2018 13:06:41 +0300 Subject: [PATCH] Implemented new module structure for Identity module. --- .../MicroserviceDemo.Web.csproj | 1 + .../MicroservicesDemoWebModule.cs | 2 +- .../AbpIdentityHttpApiHostModule.cs | 6 +- .../Volo.Abp.Identity.HttpApi.Host.csproj | 1 + .../Volo.Abp.Identity.HttpApi.csproj | 2 +- .../Abp/Identity/AbpIdentityHttpApiModule.cs | 17 +---- .../Abp/Identity/IdentityRoleController.cs | 65 +++++++++++++++++ .../Abp/Identity/IdentityUserController.cs | 69 +++++++++++++++++++ .../AbpIdentityWebModule.cs | 2 +- .../Volo.Abp.Identity.Web.csproj | 2 +- .../Volo/Abp/MultiTenancy/TenantController.cs | 10 +-- 11 files changed, 152 insertions(+), 25 deletions(-) create mode 100644 src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs create mode 100644 src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs diff --git a/src/MicroserviceDemo/MicroserviceDemo.Web/MicroserviceDemo.Web.csproj b/src/MicroserviceDemo/MicroserviceDemo.Web/MicroserviceDemo.Web.csproj index da11019dd7..1e11edff91 100644 --- a/src/MicroserviceDemo/MicroserviceDemo.Web/MicroserviceDemo.Web.csproj +++ b/src/MicroserviceDemo/MicroserviceDemo.Web/MicroserviceDemo.Web.csproj @@ -28,6 +28,7 @@ + diff --git a/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs b/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs index 7b7070d75b..c26d0e5644 100644 --- a/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs +++ b/src/MicroserviceDemo/MicroserviceDemo.Web/MicroservicesDemoWebModule.cs @@ -28,7 +28,7 @@ namespace MicroserviceDemo.Web { [DependsOn(typeof(AbpAutofacModule))] [DependsOn(typeof(AbpPermissionsEntityFrameworkCoreModule))] - [DependsOn(typeof(AbpIdentityHttpApiModule))] + [DependsOn(typeof(AbpIdentityApplicationModule))] [DependsOn(typeof(AbpIdentityWebModule))] [DependsOn(typeof(AbpIdentityEntityFrameworkCoreModule))] [DependsOn(typeof(AbpMultiTenancyHttpApiClientModule))] diff --git a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs index 333869058a..03f463bc32 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs +++ b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs @@ -18,7 +18,11 @@ using Volo.Abp.Modularity; namespace Volo.Abp.Identity.HttpApi.Host { - [DependsOn(typeof(AbpIdentityHttpApiModule), typeof(AbpIdentityEntityFrameworkCoreModule), typeof(AbpAutofacModule))] + [DependsOn( + typeof(AbpIdentityApplicationModule), + typeof(AbpIdentityEntityFrameworkCoreModule), + typeof(AbpIdentityHttpApiModule), + typeof(AbpAutofacModule))] public class AbpIdentityHttpApiHostModule : AbpModule { public override void PreConfigureServices(IServiceCollection services) diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj b/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj index e600491b34..00fd64b080 100644 --- a/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj +++ b/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.csproj @@ -19,6 +19,7 @@ + diff --git a/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.csproj b/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.csproj index 1ea55ec836..17b43c8e71 100644 --- a/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.csproj +++ b/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.csproj @@ -19,7 +19,7 @@ - + diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs index 4430047ed9..69891d1ccb 100644 --- a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs @@ -1,28 +1,15 @@ -using System; -using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.DependencyInjection; using Volo.Abp.AspNetCore.Mvc; using Volo.Abp.Modularity; namespace Volo.Abp.Identity { - [DependsOn(typeof(AbpIdentityApplicationModule), typeof(AbpAspNetCoreMvcModule))] + [DependsOn(typeof(AbpIdentityApplicationContractsModule), typeof(AbpAspNetCoreMvcModule))] public class AbpIdentityHttpApiModule : AbpModule { public override void ConfigureServices(IServiceCollection services) { services.AddAssemblyOf(); - - services.Configure(options => - { - options.ConventionalControllers.Create( - typeof(AbpIdentityApplicationModule).Assembly, - opts => - { - opts.RootPath = "identity"; - opts.UrlControllerNameNormalizer = context => context.ControllerName.RemovePreFix("Identity"); - } - ); - }); } } } \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs new file mode 100644 index 0000000000..99a590ca7a --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityRoleController.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Permissions; + +namespace Volo.Abp.Identity +{ + [RemoteService] + [Area("identity")] + [Controller] + [ControllerName("Role")] + public class IdentityRoleController : IIdentityRoleAppService, ITransientDependency + { + private readonly IIdentityRoleAppService _roleAppService; + + public IdentityRoleController(IIdentityRoleAppService roleAppService) + { + _roleAppService = roleAppService; + } + + public virtual Task GetAsync(Guid id) + { + return _roleAppService.GetAsync(id); + } + + public virtual Task> GetListAsync(GetIdentityRolesInput input) + { + return _roleAppService.GetListAsync(input); + } + + public virtual Task CreateAsync(IdentityRoleCreateDto input) + { + return _roleAppService.CreateAsync(input); + } + + public virtual Task UpdateAsync(Guid id, IdentityRoleUpdateDto input) + { + return _roleAppService.UpdateAsync(id, input); + } + + public virtual Task DeleteAsync(Guid id) + { + return _roleAppService.DeleteAsync(id); + } + + public virtual Task> GetAllListAsync() + { + return _roleAppService.GetAllListAsync(); + } + + public virtual Task GetPermissionsAsync(Guid id) + { + return _roleAppService.GetPermissionsAsync(id); + } + + public virtual Task UpdatePermissionsAsync(Guid id, UpdatePermissionsDto input) + { + return _roleAppService.UpdatePermissionsAsync(id, input); + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs new file mode 100644 index 0000000000..42ac0412f1 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUserController.cs @@ -0,0 +1,69 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Application.Services; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Permissions; + +namespace Volo.Abp.Identity +{ + [RemoteService] + [Area("identity")] + [Controller] + [ControllerName("User")] + public class IdentityUserController : IIdentityUserAppService, ITransientDependency //TODO: Try to implement these type wrapper controllers automatically! + { + private readonly IIdentityUserAppService _userAppService; + + public IdentityUserController(IIdentityUserAppService userAppService) + { + _userAppService = userAppService; + } + + public virtual Task GetAsync(Guid id) + { + return _userAppService.GetAsync(id); + } + + public virtual Task> GetListAsync(GetIdentityUsersInput input) + { + return _userAppService.GetListAsync(input); + } + + public virtual Task CreateAsync(IdentityUserCreateDto input) + { + return _userAppService.CreateAsync(input); + } + + public virtual Task UpdateAsync(Guid id, IdentityUserUpdateDto input) + { + return _userAppService.UpdateAsync(id, input); + } + + public virtual Task DeleteAsync(Guid id) + { + return _userAppService.DeleteAsync(id); + } + + public virtual Task> GetRolesAsync(Guid id) + { + return _userAppService.GetRolesAsync(id); + } + + public virtual Task UpdateRolesAsync(Guid id, IdentityUserUpdateRolesDto input) + { + return _userAppService.UpdateRolesAsync(id, input); + } + + public virtual Task GetPermissionsAsync(Guid id) + { + return _userAppService.GetPermissionsAsync(id); + } + + public virtual Task UpdatePermissionsAsync(Guid id, UpdatePermissionsDto input) + { + return _userAppService.UpdatePermissionsAsync(id, input); + } + } +} diff --git a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs index 6e2472e1a6..94d80d4fab 100644 --- a/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs +++ b/src/Volo.Abp.Identity.Web/AbpIdentityWebModule.cs @@ -13,7 +13,7 @@ using Volo.Abp.VirtualFileSystem; namespace Volo.Abp.Identity.Web { - [DependsOn(typeof(AbpIdentityApplicationContractsModule))] + [DependsOn(typeof(AbpIdentityHttpApiModule))] [DependsOn(typeof(AbpAspNetCoreMvcUiBootstrapModule))] [DependsOn(typeof(AbpAutoMapperModule))] [DependsOn(typeof(AbpPermissionsWebModule))] diff --git a/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj b/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj index b4c77f791d..8f83907662 100644 --- a/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj +++ b/src/Volo.Abp.Identity.Web/Volo.Abp.Identity.Web.csproj @@ -22,8 +22,8 @@ - + diff --git a/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/TenantController.cs b/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/TenantController.cs index 5bd228f768..8963cf2cf7 100644 --- a/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/TenantController.cs +++ b/src/Volo.Abp.MultiTenancy.HttpApi/Volo/Abp/MultiTenancy/TenantController.cs @@ -19,27 +19,27 @@ namespace Volo.Abp.MultiTenancy _service = service; } - public Task GetAsync(Guid id) + public virtual Task GetAsync(Guid id) { return _service.GetAsync(id); } - public Task> GetListAsync(GetTenantsInput input) + public virtual Task> GetListAsync(GetTenantsInput input) { return _service.GetListAsync(input); } - public Task CreateAsync(TenantCreateDto input) + public virtual Task CreateAsync(TenantCreateDto input) { return _service.CreateAsync(input); } - public Task UpdateAsync(Guid id, TenantUpdateDto input) + public virtual Task UpdateAsync(Guid id, TenantUpdateDto input) { return _service.UpdateAsync(id, input); } - public Task DeleteAsync(Guid id) + public virtual Task DeleteAsync(Guid id) { return _service.DeleteAsync(id); }