From cbbb13683433dcb14d84caaff85dd2cc2d8cefcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 23 Feb 2017 16:00:08 +0300 Subject: [PATCH] Added initial Identity rest API. --- Volo.Abp.sln | 28 +++++++++ .../AbpDeskDbConfigurer.cs | 2 +- src/AbpDesk/AbpDesk.Web.Mvc/project.json | 1 + .../EntityFrameworkCore/EfCoreRepository.cs | 6 ++ .../Properties/AssemblyInfo.cs | 19 ++++++ ...o.Abp.Identity.Application.Contracts.xproj | 20 ++++++ .../Volo/Abp/Identity/IUserAppService.cs | 14 +++++ .../Volo/Abp/Identity/IdentityUserDto.cs | 11 ++++ .../project.json | 13 ++++ .../Properties/AssemblyInfo.cs | 19 ++++++ .../Volo.Abp.Identity.Application.xproj | 20 ++++++ .../Identity/AbpIdentityApplicationModule.cs | 14 +++++ .../Volo/Abp/Identity/UserAppService.cs | 60 ++++++++++++++++++ .../project.json | 14 +++++ .../AbpIdentityHttpApiHostModule.cs | 62 +++++++++++++++++++ src/Volo.Abp.Identity.HttpApi.Host/Program.cs | 20 ++++++ .../Properties/launchSettings.json | 27 ++++++++ src/Volo.Abp.Identity.HttpApi.Host/Startup.cs | 23 +++++++ .../Volo.Abp.Identity.HttpApi.Host.xproj | 25 ++++++++ .../appsettings.Staging.json | 5 ++ .../appsettings.json | 5 ++ .../project.json | 60 ++++++++++++++++++ src/Volo.Abp.Identity.HttpApi.Host/web.config | 14 +++++ .../Properties/AssemblyInfo.cs | 19 ++++++ .../Volo.Abp.Identity.HttpApi.xproj | 20 ++++++ .../Abp/Identity/AbpIdentityHttpApiModule.cs | 15 +++++ .../Abp/Identity/IdentityUsersController.cs | 33 ++++++++++ src/Volo.Abp.Identity.HttpApi/project.json | 14 +++++ .../Volo/Abp/Identity/IdentityUser.cs | 1 - .../Repositories/MongoDB/MongoDbRepository.cs | 6 ++ .../Application/Services/Dtos/EntityDto.cs | 23 +++++++ .../Application/Services/Dtos/IEntityDto.cs | 16 ++--- .../Abp/Domain/Repositories/IRepository.cs | 14 +++++ .../Repositories/QueryableRepositoryBase.cs | 5 ++ .../Abp/Domain/Repositories/RepositoryBase.cs | 8 +++ .../RepositoryRegistration_Tests.cs | 5 ++ 36 files changed, 652 insertions(+), 9 deletions(-) create mode 100644 src/Volo.Abp.Identity.Application.Contracts/Properties/AssemblyInfo.cs create mode 100644 src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.xproj create mode 100644 src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IUserAppService.cs create mode 100644 src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs create mode 100644 src/Volo.Abp.Identity.Application.Contracts/project.json create mode 100644 src/Volo.Abp.Identity.Application/Properties/AssemblyInfo.cs create mode 100644 src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.xproj create mode 100644 src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs create mode 100644 src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs create mode 100644 src/Volo.Abp.Identity.Application/project.json create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/Program.cs create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/Properties/launchSettings.json create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/Startup.cs create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.xproj create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/appsettings.Staging.json create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/appsettings.json create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/project.json create mode 100644 src/Volo.Abp.Identity.HttpApi.Host/web.config create mode 100644 src/Volo.Abp.Identity.HttpApi/Properties/AssemblyInfo.cs create mode 100644 src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.xproj create mode 100644 src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs create mode 100644 src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUsersController.cs create mode 100644 src/Volo.Abp.Identity.HttpApi/project.json diff --git a/Volo.Abp.sln b/Volo.Abp.sln index a2b93b71e6..cd0e911ec8 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -92,6 +92,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Abp.UI", "Abp.UI", "{6F776E EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.AspNetCore.Mvc.UI.Bootstrap", "src\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap\Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.xproj", "{C761A3F7-787D-4C7E-A41C-5FAB07F6B774}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.Application.Contracts", "src\Volo.Abp.Identity.Application.Contracts\Volo.Abp.Identity.Application.Contracts.xproj", "{C714A3AB-8402-4DC2-B120-ACCB2E29BD8F}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.Application", "src\Volo.Abp.Identity.Application\Volo.Abp.Identity.Application.xproj", "{54592671-9CB6-48AE-9AE0-84CD016E87FF}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.HttpApi", "src\Volo.Abp.Identity.HttpApi\Volo.Abp.Identity.HttpApi.xproj", "{57FCA6CB-9D99-411E-8ABF-20ACFBD61D61}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Volo.Abp.Identity.HttpApi.Host", "src\Volo.Abp.Identity.HttpApi.Host\Volo.Abp.Identity.HttpApi.Host.xproj", "{EB902D57-C047-4CDF-828B-FDC204AC7398}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -214,6 +222,22 @@ Global {C761A3F7-787D-4C7E-A41C-5FAB07F6B774}.Debug|Any CPU.Build.0 = Debug|Any CPU {C761A3F7-787D-4C7E-A41C-5FAB07F6B774}.Release|Any CPU.ActiveCfg = Release|Any CPU {C761A3F7-787D-4C7E-A41C-5FAB07F6B774}.Release|Any CPU.Build.0 = Release|Any CPU + {C714A3AB-8402-4DC2-B120-ACCB2E29BD8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C714A3AB-8402-4DC2-B120-ACCB2E29BD8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C714A3AB-8402-4DC2-B120-ACCB2E29BD8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C714A3AB-8402-4DC2-B120-ACCB2E29BD8F}.Release|Any CPU.Build.0 = Release|Any CPU + {54592671-9CB6-48AE-9AE0-84CD016E87FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {54592671-9CB6-48AE-9AE0-84CD016E87FF}.Debug|Any CPU.Build.0 = Debug|Any CPU + {54592671-9CB6-48AE-9AE0-84CD016E87FF}.Release|Any CPU.ActiveCfg = Release|Any CPU + {54592671-9CB6-48AE-9AE0-84CD016E87FF}.Release|Any CPU.Build.0 = Release|Any CPU + {57FCA6CB-9D99-411E-8ABF-20ACFBD61D61}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {57FCA6CB-9D99-411E-8ABF-20ACFBD61D61}.Debug|Any CPU.Build.0 = Debug|Any CPU + {57FCA6CB-9D99-411E-8ABF-20ACFBD61D61}.Release|Any CPU.ActiveCfg = Release|Any CPU + {57FCA6CB-9D99-411E-8ABF-20ACFBD61D61}.Release|Any CPU.Build.0 = Release|Any CPU + {EB902D57-C047-4CDF-828B-FDC204AC7398}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EB902D57-C047-4CDF-828B-FDC204AC7398}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EB902D57-C047-4CDF-828B-FDC204AC7398}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EB902D57-C047-4CDF-828B-FDC204AC7398}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -256,5 +280,9 @@ Global {B6182BF1-9EC6-403D-A42C-D6441CF7B390} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {6F776E78-862A-4147-86BA-12B6B64E8958} = {5DF0E140-0513-4D0D-BE2E-3D4D85CD70E6} {C761A3F7-787D-4C7E-A41C-5FAB07F6B774} = {6F776E78-862A-4147-86BA-12B6B64E8958} + {C714A3AB-8402-4DC2-B120-ACCB2E29BD8F} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} + {54592671-9CB6-48AE-9AE0-84CD016E87FF} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} + {57FCA6CB-9D99-411E-8ABF-20ACFBD61D61} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} + {EB902D57-C047-4CDF-828B-FDC204AC7398} = {1895A5C9-50D4-4568-9A3A-14657E615A5E} EndGlobalSection EndGlobal diff --git a/src/AbpDesk/AbpDesk.EntityFrameworkCore/AbpDesk/EntityFrameworkCore/AbpDeskDbConfigurer.cs b/src/AbpDesk/AbpDesk.EntityFrameworkCore/AbpDesk/EntityFrameworkCore/AbpDeskDbConfigurer.cs index 82dea19e9c..d65bce9c37 100644 --- a/src/AbpDesk/AbpDesk.EntityFrameworkCore/AbpDesk/EntityFrameworkCore/AbpDeskDbConfigurer.cs +++ b/src/AbpDesk/AbpDesk.EntityFrameworkCore/AbpDesk/EntityFrameworkCore/AbpDeskDbConfigurer.cs @@ -11,7 +11,7 @@ namespace AbpDesk.EntityFrameworkCore public static void Configure(IServiceCollection services, IConfigurationRoot configuration) { //Configure DbConnectionOptions by configuration file (appsettings.json) - services.Configure(configuration); + services.Configure(configuration); //TODO: Move to the application. No proper to be in EF Core package. services.Configure(options => { diff --git a/src/AbpDesk/AbpDesk.Web.Mvc/project.json b/src/AbpDesk/AbpDesk.Web.Mvc/project.json index ea06f22768..30b40f1ff4 100644 --- a/src/AbpDesk/AbpDesk.Web.Mvc/project.json +++ b/src/AbpDesk/AbpDesk.Web.Mvc/project.json @@ -12,6 +12,7 @@ "Microsoft.AspNetCore.StaticFiles": "1.1.0", "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", "Microsoft.Extensions.Configuration.Json": "1.1.0", + "AbpDesk.Application.Contracts": "1.0.0-*", "Microsoft.EntityFrameworkCore.Tools": { "type": "build", diff --git a/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs b/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs index 40eaa5ad39..d582b2fa15 100644 --- a/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs +++ b/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading; @@ -41,6 +42,11 @@ namespace Volo.Abp.Domain.Repositories.EntityFrameworkCore return DbSet.AsQueryable(); } + public override Task> GetListAsync(CancellationToken cancellationToken = new CancellationToken()) + { + return DbSet.ToListAsync(cancellationToken); + } + public override async Task GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) { var entity = await FindAsync(id, cancellationToken); diff --git a/src/Volo.Abp.Identity.Application.Contracts/Properties/AssemblyInfo.cs b/src/Volo.Abp.Identity.Application.Contracts/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..bd5ee37947 --- /dev/null +++ b/src/Volo.Abp.Identity.Application.Contracts/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Volo.Abp.Identity.Application.Contracts")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("c714a3ab-8402-4dc2-b120-accb2e29bd8f")] diff --git a/src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.xproj b/src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.xproj new file mode 100644 index 0000000000..d65cea4271 --- /dev/null +++ b/src/Volo.Abp.Identity.Application.Contracts/Volo.Abp.Identity.Application.Contracts.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + c714a3ab-8402-4dc2-b120-accb2e29bd8f + + + .\obj + .\bin\ + v4.6.1 + + + 2.0 + + + \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IUserAppService.cs b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IUserAppService.cs new file mode 100644 index 0000000000..13d8f20d9e --- /dev/null +++ b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IUserAppService.cs @@ -0,0 +1,14 @@ +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Services; +using Volo.Abp.Application.Services.Dtos; + +namespace Volo.Abp.Identity +{ + public interface IUserAppService : IApplicationService + { + Task> GetAll(); + + Task Get(Guid id); + } +} diff --git a/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs new file mode 100644 index 0000000000..26e2cd5229 --- /dev/null +++ b/src/Volo.Abp.Identity.Application.Contracts/Volo/Abp/Identity/IdentityUserDto.cs @@ -0,0 +1,11 @@ +using Volo.Abp.Application.Services.Dtos; + +namespace Volo.Abp.Identity +{ + public class IdentityUserDto : EntityDto + { + public string UserName { get; set; } + + public string Email { get; set; } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Application.Contracts/project.json b/src/Volo.Abp.Identity.Application.Contracts/project.json new file mode 100644 index 0000000000..617f95fb0e --- /dev/null +++ b/src/Volo.Abp.Identity.Application.Contracts/project.json @@ -0,0 +1,13 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Volo.Abp": "1.0.0-*" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Volo.Abp.Identity.Application/Properties/AssemblyInfo.cs b/src/Volo.Abp.Identity.Application/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..e1486fa65e --- /dev/null +++ b/src/Volo.Abp.Identity.Application/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Volo.Abp.Identity.Application")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("54592671-9cb6-48ae-9ae0-84cd016e87ff")] diff --git a/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.xproj b/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.xproj new file mode 100644 index 0000000000..b79d02e301 --- /dev/null +++ b/src/Volo.Abp.Identity.Application/Volo.Abp.Identity.Application.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 54592671-9cb6-48ae-9ae0-84cd016e87ff + + + .\obj + .\bin\ + v4.6.1 + + + 2.0 + + + \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs new file mode 100644 index 0000000000..977357bc2a --- /dev/null +++ b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/AbpIdentityApplicationModule.cs @@ -0,0 +1,14 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Identity +{ + [DependsOn(typeof(AbpIdentityModule))] + public class AbpIdentityApplicationModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs new file mode 100644 index 0000000000..5cafc579fb --- /dev/null +++ b/src/Volo.Abp.Identity.Application/Volo/Abp/Identity/UserAppService.cs @@ -0,0 +1,60 @@ +using System; +using System.Linq; +using System.Threading.Tasks; +using Volo.Abp.Application.Services.Dtos; +using Volo.Abp.Uow; + +namespace Volo.Abp.Identity +{ + public class UserAppService : IUserAppService + { + private readonly IIdentityUserRepository _userRepository; + private readonly IUnitOfWorkManager _unitOfWorkManager; + + public UserAppService( + IIdentityUserRepository userRepository, + IUnitOfWorkManager unitOfWorkManager) + { + _userRepository = userRepository; + _unitOfWorkManager = unitOfWorkManager; + } + + public async Task> GetAll() + { + //Use conventional unit of work for application services when it's available! + using (var unitOfWork = _unitOfWorkManager.Begin()) + { + var users = (await _userRepository.GetListAsync()) + .Select(u => new IdentityUserDto + { + Id = u.Id, + Email = u.Email, + UserName = u.UserName + }) + .ToList(); + + await unitOfWork.CompleteAsync(); + + return new ListResultDto(users); + } + } + + public async Task Get(Guid id) + { + //Use conventional unit of work for application services when it's available! + using (var unitOfWork = _unitOfWorkManager.Begin()) + { + var user = await _userRepository.GetAsync(id); + + await unitOfWork.CompleteAsync(); + + return new IdentityUserDto + { + Id = user.Id, + UserName = user.UserName, + Email = user.Email + }; + } + } + } +} diff --git a/src/Volo.Abp.Identity.Application/project.json b/src/Volo.Abp.Identity.Application/project.json new file mode 100644 index 0000000000..24b67e1fe3 --- /dev/null +++ b/src/Volo.Abp.Identity.Application/project.json @@ -0,0 +1,14 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Volo.Abp.Identity": "1.0.0-*", + "Volo.Abp.Identity.Application.Contracts": "1.0.0-*" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs new file mode 100644 index 0000000000..7188072d3a --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/AbpIdentityHttpApiHostModule.cs @@ -0,0 +1,62 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Volo.Abp.AspNetCore.Modularity; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Identity.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Identity.HttpApi.Host +{ + [DependsOn(typeof(AbpIdentityHttpApiModule), typeof(AbpIdentityEntityFrameworkCoreModule))] + public class AbpIdentityHttpApiHostModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + var hostingEnvironment = services.GetSingletonInstance(); + var configuration = BuildConfiguration(hostingEnvironment); + + services.Configure(configuration); + + services.Configure(options => + { + //Configures all dbcontextes to use Sql Server with calculated connection string + options.Configure(context => + { + context.DbContextOptions.UseSqlServer(context.ConnectionString); + }); + }); + + services.AddMvc(); + services.AddAssemblyOf(); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + + context.GetLoggerFactory().AddConsole().AddDebug(); + + if (context.GetEnvironment().IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseMvc(); //No need to a default route + } + + private static IConfigurationRoot BuildConfiguration(IHostingEnvironment env) + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true, reloadOnChange: true); + + return builder.Build(); + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Program.cs b/src/Volo.Abp.Identity.HttpApi.Host/Program.cs new file mode 100644 index 0000000000..ccf8ec917f --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/Program.cs @@ -0,0 +1,20 @@ +using System.IO; +using Microsoft.AspNetCore.Hosting; + +namespace Volo.Abp.Identity.HttpApi.Host +{ + public class Program + { + public static void Main(string[] args) + { + var host = new WebHostBuilder() + .UseKestrel() + .UseContentRoot(Directory.GetCurrentDirectory()) + .UseIISIntegration() + .UseStartup() + .Build(); + + host.Run(); + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Properties/launchSettings.json b/src/Volo.Abp.Identity.HttpApi.Host/Properties/launchSettings.json new file mode 100644 index 0000000000..41f665cad8 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:63290/", + "sslPort": 0 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "Volo.Abp.Identity.HttpApi.Host": { + "commandName": "Project", + "launchBrowser": true, + "launchUrl": "http://localhost:5000", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Startup.cs b/src/Volo.Abp.Identity.HttpApi.Host/Startup.cs new file mode 100644 index 0000000000..bbde97e61a --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/Startup.cs @@ -0,0 +1,23 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace Volo.Abp.Identity.HttpApi.Host +{ + public class Startup + { + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.xproj b/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.xproj new file mode 100644 index 0000000000..e58ab94ee4 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/Volo.Abp.Identity.HttpApi.Host.xproj @@ -0,0 +1,25 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + + eb902d57-c047-4cdf-828b-fdc204ac7398 + Volo.Abp.Identity.HttpApi.Host + .\obj + .\bin\ + v4.6.1 + + + + 2.0 + + + + + + + diff --git a/src/Volo.Abp.Identity.HttpApi.Host/appsettings.Staging.json b/src/Volo.Abp.Identity.HttpApi.Host/appsettings.Staging.json new file mode 100644 index 0000000000..3a6dc58fce --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/appsettings.Staging.json @@ -0,0 +1,5 @@ +{ + "ConnectionStrings": { + "Default": "Server=192.168.1.36;Database=AbpDesk;User=sa;Password=123qwe;" + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/appsettings.json b/src/Volo.Abp.Identity.HttpApi.Host/appsettings.json new file mode 100644 index 0000000000..0f39b1b157 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/appsettings.json @@ -0,0 +1,5 @@ +{ + "ConnectionStrings": { + "Default": "Server=localhost;Database=AbpDesk;Trusted_Connection=True;" + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/project.json b/src/Volo.Abp.Identity.HttpApi.Host/project.json new file mode 100644 index 0000000000..db1c281c1f --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/project.json @@ -0,0 +1,60 @@ +{ + "dependencies": { + "Microsoft.NETCore.App": { + "version": "1.1.0", + "type": "platform" + }, + "Microsoft.AspNetCore.Diagnostics": "1.1.0", + "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0", + "Microsoft.AspNetCore.Server.Kestrel": "1.1.0", + "Microsoft.Extensions.Logging.Console": "1.1.0", + "Microsoft.Extensions.Logging.Debug": "1.1.0", + "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", + "Microsoft.Extensions.Configuration.Json": "1.1.0", + + "Microsoft.EntityFrameworkCore.Tools": { + "type": "build", + "version": "1.1.0-preview4-final" + }, + + "Volo.Abp.Identity.EntityFrameworkCore": "1.0.0-*", + "Volo.Abp.Identity.HttpApi": "1.0.0-*" + }, + + "tools": { + "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final", + "Microsoft.EntityFrameworkCore.Tools": "1.1.0-preview4-final" + }, + + "frameworks": { + "netcoreapp1.1": { + "imports": [ + "dotnet5.6", + "portable-net45+win8" + ] + } + }, + + "buildOptions": { + "emitEntryPoint": true, + "preserveCompilationContext": true + }, + + "runtimeOptions": { + "configProperties": { + "System.GC.Server": true + } + }, + + "publishOptions": { + "include": [ + "wwwroot", + "web.config", + "appsettings.json" + ] + }, + + "scripts": { + "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ] + } +} diff --git a/src/Volo.Abp.Identity.HttpApi.Host/web.config b/src/Volo.Abp.Identity.HttpApi.Host/web.config new file mode 100644 index 0000000000..dc0514fca5 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi.Host/web.config @@ -0,0 +1,14 @@ + + + + + + + + + + + + diff --git a/src/Volo.Abp.Identity.HttpApi/Properties/AssemblyInfo.cs b/src/Volo.Abp.Identity.HttpApi/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..db876d34de --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/Properties/AssemblyInfo.cs @@ -0,0 +1,19 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Volo.Abp.Identity.HttpApi")] +[assembly: AssemblyTrademark("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("57fca6cb-9d99-411e-8abf-20acfbd61d61")] diff --git a/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.xproj b/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.xproj new file mode 100644 index 0000000000..bd4aa1d2e8 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/Volo.Abp.Identity.HttpApi.xproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 57fca6cb-9d99-411e-8abf-20acfbd61d61 + + + .\obj + .\bin\ + v4.6.1 + + + 2.0 + + + \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs new file mode 100644 index 0000000000..10fc94d0af --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/AbpIdentityHttpApiModule.cs @@ -0,0 +1,15 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Modularity; + +namespace Volo.Abp.Identity +{ + [DependsOn(typeof(AbpIdentityApplicationModule), typeof(AbpAspNetCoreMvcModule))] + public class AbpIdentityHttpApiModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + } + } +} \ No newline at end of file diff --git a/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUsersController.cs b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUsersController.cs new file mode 100644 index 0000000000..5615f42351 --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/Volo/Abp/Identity/IdentityUsersController.cs @@ -0,0 +1,33 @@ +using System; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.Application.Services.Dtos; +using Volo.Abp.AspNetCore.Mvc; + +namespace Volo.Abp.Identity +{ + [Route("api/identity/users")] + public class IdentityUsersController : AbpController + { + private readonly IUserAppService _userAppService; + + public IdentityUsersController(IUserAppService userAppService) + { + _userAppService = userAppService; + } + + [HttpGet] + [Route("")] + public Task> GetAll() + { + return _userAppService.GetAll(); + } + + [HttpGet] + [Route("{id}")] + public Task Get(Guid id) + { + return _userAppService.Get(id); + } + } +} diff --git a/src/Volo.Abp.Identity.HttpApi/project.json b/src/Volo.Abp.Identity.HttpApi/project.json new file mode 100644 index 0000000000..a966e5b21c --- /dev/null +++ b/src/Volo.Abp.Identity.HttpApi/project.json @@ -0,0 +1,14 @@ +{ + "version": "1.0.0-*", + + "dependencies": { + "Volo.Abp.AspNetCore.Mvc": "1.0.0-*", + "Volo.Abp.Identity.Application": "1.0.0-*" + }, + + "frameworks": { + "netstandard1.6": { + "imports": "dnxcore50" + } + } +} diff --git a/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs b/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs index 73eff54d4b..d30cbac50a 100644 --- a/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs +++ b/src/Volo.Abp.Identity/Volo/Abp/Identity/IdentityUser.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Collections.Immutable; using System.Collections.ObjectModel; using System.Linq; using System.Security.Claims; diff --git a/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs b/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs index 550f17fd8e..afb2bbcfe5 100644 --- a/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs +++ b/src/Volo.Abp.MongoDB/Volo/Abp/Domain/Repositories/MongoDB/MongoDbRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Threading; @@ -38,6 +39,11 @@ namespace Volo.Abp.Domain.Repositories.MongoDB //TODO: Override other methods? + public override async Task> GetListAsync(CancellationToken cancellationToken = new CancellationToken()) + { + return await (await Collection.FindAsync(Builders.Filter.Empty, cancellationToken: cancellationToken)).ToListAsync(cancellationToken); + } + public override async Task GetAsync(TPrimaryKey id, CancellationToken cancellationToken = default(CancellationToken)) { var entity = await FindAsync(id, cancellationToken); diff --git a/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/EntityDto.cs b/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/EntityDto.cs index 9c4cafd61f..b33e91e6dc 100644 --- a/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/EntityDto.cs +++ b/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/EntityDto.cs @@ -1,5 +1,28 @@ +using System; + namespace Volo.Abp.Application.Services.Dtos { + public class EntityDto : EntityDto, IEntityDto + { + /// + /// Creates a new object. + /// + public EntityDto() + { + + } + + /// + /// Creates a new object. + /// + /// Id of the entity + public EntityDto(Guid id) + : base(id) + { + + } + } + /// /// Implements common properties for entity based DTOs. /// diff --git a/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/IEntityDto.cs b/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/IEntityDto.cs index 250c40c677..731a29b638 100644 --- a/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/IEntityDto.cs +++ b/src/Volo.Abp/Volo/Abp/Application/Services/Dtos/IEntityDto.cs @@ -1,12 +1,14 @@ -namespace Volo.Abp.Application.Services.Dtos +using System; + +namespace Volo.Abp.Application.Services.Dtos { - ///// - ///// A shortcut of for most used primary key type (). - ///// - //public interface IEntityDto : IEntityDto - //{ + /// + /// A shortcut of for default primary key type (). + /// + public interface IEntityDto : IEntityDto + { - //} + } /// /// Defines common properties for entity based DTOs. diff --git a/src/Volo.Abp/Volo/Abp/Domain/Repositories/IRepository.cs b/src/Volo.Abp/Volo/Abp/Domain/Repositories/IRepository.cs index 23a1361ba4..eee5036345 100644 --- a/src/Volo.Abp/Volo/Abp/Domain/Repositories/IRepository.cs +++ b/src/Volo.Abp/Volo/Abp/Domain/Repositories/IRepository.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using JetBrains.Annotations; @@ -21,6 +22,19 @@ namespace Volo.Abp.Domain.Repositories public interface IRepository : IRepository where TEntity : class, IEntity { + /// + /// Get list of all entities without any filtering. + /// + /// List of entities + List GetList(); + + /// + /// Get list of all entities without any filtering. + /// + /// A to observe while waiting for the task to complete. + /// List of entities + Task> GetListAsync(CancellationToken cancellationToken = default(CancellationToken)); + /// /// Gets an entity with given primary key. /// Throws if can not find an entity with given id. diff --git a/src/Volo.Abp/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs b/src/Volo.Abp/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs index 7e9866179f..46af8d8e62 100644 --- a/src/Volo.Abp/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs +++ b/src/Volo.Abp/Volo/Abp/Domain/Repositories/QueryableRepositoryBase.cs @@ -36,6 +36,11 @@ namespace Volo.Abp.Domain.Repositories protected abstract IQueryable GetQueryable(); + public override List GetList() + { + return GetQueryable().ToList(); + } + public override TEntity Find(TPrimaryKey id) { return GetQueryable().FirstOrDefault(CreateEqualityExpressionForId(id)); diff --git a/src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryBase.cs b/src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryBase.cs index b80d7d14b9..edf583c1a9 100644 --- a/src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryBase.cs +++ b/src/Volo.Abp/Volo/Abp/Domain/Repositories/RepositoryBase.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; @@ -15,6 +16,13 @@ namespace Volo.Abp.Domain.Repositories public abstract class RepositoryBase : IRepository where TEntity : class, IEntity { + public abstract List GetList(); + + public virtual Task> GetListAsync(CancellationToken cancellationToken = new CancellationToken()) + { + return Task.FromResult(GetList()); + } + public virtual TEntity Get(TPrimaryKey id) { var entity = Find(id); diff --git a/test/Volo.Abp.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs b/test/Volo.Abp.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs index 59c444eed7..bfc6f5e0a0 100644 --- a/test/Volo.Abp.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/Domain/Repositories/RepositoryRegistration_Tests.cs @@ -164,6 +164,11 @@ namespace Volo.Abp.Domain.Repositories { throw new NotImplementedException(); } + + public override List GetList() + { + throw new NotImplementedException(); + } } public class MyTestAggregateRootWithDefaultPkCustomRepository : MyTestDefaultRepository