mirror of https://github.com/abpframework/abp.git
118 changed files with 4003 additions and 578 deletions
@ -1,7 +1,7 @@ |
|||||
<Project> |
<Project> |
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<LangVersion>latest</LangVersion> |
<LangVersion>latest</LangVersion> |
||||
<Version>0.16.0</Version> |
<Version>1.0.0</Version> |
||||
<NoWarn>$(NoWarn);CS1591</NoWarn> |
<NoWarn>$(NoWarn);CS1591</NoWarn> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
</Project> |
</Project> |
||||
@ -0,0 +1,21 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace>Acme.BookStore</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Acme.BookStore.Domain.Shared\Acme.BookStore.Domain.Shared.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Identity.Application.Contracts" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Application.Contracts" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.Application.Contracts" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.Application.Contracts" Version="0.17.0.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -1,10 +1,8 @@ |
|||||
using System; |
using System; |
||||
using Volo.Abp.Application.Dtos; |
using Volo.Abp.Application.Dtos; |
||||
using Volo.Abp.AutoMapper; |
|
||||
|
|
||||
namespace Acme.BookStore |
namespace Acme.BookStore |
||||
{ |
{ |
||||
[AutoMapFrom(typeof(Book))] |
|
||||
public class BookDto : AuditedEntityDto<Guid> |
public class BookDto : AuditedEntityDto<Guid> |
||||
{ |
{ |
||||
public string Name { get; set; } |
public string Name { get; set; } |
||||
@ -0,0 +1,20 @@ |
|||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BookStoreDomainSharedModule), |
||||
|
typeof(AbpFeatureManagementApplicationContractsModule), |
||||
|
typeof(AbpIdentityApplicationContractsModule), |
||||
|
typeof(AbpPermissionManagementApplicationContractsModule), |
||||
|
typeof(AbpTenantManagementApplicationContractsModule) |
||||
|
)] |
||||
|
public class BookStoreApplicationContractsModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<OutputType>Exe</OutputType> |
||||
|
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<None Remove="appsettings.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<Content Include="appsettings.json"> |
||||
|
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory> |
||||
|
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
|
</Content> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.2.4" /> |
||||
|
<PackageReference Include="Serilog.Extensions.Logging" Version="2.0.4" /> |
||||
|
<PackageReference Include="Serilog.Sinks.File" Version="4.0.0" /> |
||||
|
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Autofac" Version="0.17.0.0" /> |
||||
|
<ProjectReference Include="..\Acme.BookStore.Application.Contracts\Acme.BookStore.Application.Contracts.csproj" /> |
||||
|
<ProjectReference Include="..\Acme.BookStore.EntityFrameworkCore.DbMigrations\Acme.BookStore.EntityFrameworkCore.DbMigrations.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,16 @@ |
|||||
|
using Acme.BookStore.EntityFrameworkCore; |
||||
|
using Volo.Abp.Autofac; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Acme.BookStore.DbMigrator |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpAutofacModule), |
||||
|
typeof(BookStoreEntityFrameworkCoreDbMigrationsModule), |
||||
|
typeof(BookStoreApplicationContractsModule) |
||||
|
)] |
||||
|
public class BookStoreDbMigratorModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
using System.IO; |
||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Acme.BookStore.Data; |
||||
|
using Serilog; |
||||
|
using Serilog.Events; |
||||
|
using Volo.Abp; |
||||
|
using Volo.Abp.Threading; |
||||
|
|
||||
|
namespace Acme.BookStore.DbMigrator |
||||
|
{ |
||||
|
class Program |
||||
|
{ |
||||
|
static void Main(string[] args) |
||||
|
{ |
||||
|
ConfigureLogging(); |
||||
|
|
||||
|
using (var application = AbpApplicationFactory.Create<BookStoreDbMigratorModule>(options => |
||||
|
{ |
||||
|
options.UseAutofac(); |
||||
|
options.Services.AddLogging(c => c.AddSerilog()); |
||||
|
})) |
||||
|
{ |
||||
|
application.Initialize(); |
||||
|
|
||||
|
AsyncHelper.RunSync( |
||||
|
() => application |
||||
|
.ServiceProvider |
||||
|
.GetRequiredService<BookStoreDbMigrationService>() |
||||
|
.MigrateAsync() |
||||
|
); |
||||
|
|
||||
|
application.Shutdown(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private static void ConfigureLogging() |
||||
|
{ |
||||
|
Log.Logger = new LoggerConfiguration() |
||||
|
.MinimumLevel.Information() |
||||
|
.MinimumLevel.Override("Microsoft", LogEventLevel.Warning) |
||||
|
.MinimumLevel.Override("Volo.Abp", LogEventLevel.Warning) |
||||
|
#if DEBUG
|
||||
|
.MinimumLevel.Override("Acme.BookStore", LogEventLevel.Debug) |
||||
|
#else
|
||||
|
.MinimumLevel.Override("Acme.BookStore", LogEventLevel.Information) |
||||
|
#endif
|
||||
|
.Enrich.FromLogContext() |
||||
|
.WriteTo.File(Path.Combine(Directory.GetCurrentDirectory(), "Logs/logs.txt")) |
||||
|
.WriteTo.Console() |
||||
|
.CreateLogger(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
{ |
||||
|
"ConnectionStrings": { |
||||
|
"Default": "Server=localhost;Database=BookStore;Trusted_Connection=True;MultipleActiveResultSets=true" |
||||
|
}, |
||||
|
"IdentityServer": { |
||||
|
"Clients": { |
||||
|
"BookStore_Web": { |
||||
|
"ClientId": "BookStore_Web", |
||||
|
"RootUrl": "https://localhost:44314/" |
||||
|
}, |
||||
|
"BookStore_ConsoleTestApp": { |
||||
|
"ClientId": "BookStore_ConsoleTestApp" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,26 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace>Acme.BookStore</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Identity.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.IdentityServer.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.AuditLogging.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Shared" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.SettingManagement.Domain.Shared" Version="0.17.0.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<EmbeddedResource Include="Localization\BookStore\*.json" /> |
||||
|
<Content Remove="Localization\BookStore\*.json" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
public static class BookStoreDomainErrorCodes |
||||
|
{ |
||||
|
/* You can add your business exception error codes here, as constants */ |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,45 @@ |
|||||
|
using Acme.BookStore.Localization; |
||||
|
using Volo.Abp.AuditLogging; |
||||
|
using Volo.Abp.BackgroundJobs; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.IdentityServer; |
||||
|
using Volo.Abp.Localization; |
||||
|
using Volo.Abp.Localization.Resources.AbpValidation; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.SettingManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
using Volo.Abp.VirtualFileSystem; |
||||
|
|
||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(AbpAuditLoggingDomainSharedModule), |
||||
|
typeof(BackgroundJobsDomainSharedModule), |
||||
|
typeof(AbpFeatureManagementDomainSharedModule), |
||||
|
typeof(AbpIdentityDomainSharedModule), |
||||
|
typeof(AbpIdentityServerDomainSharedModule), |
||||
|
typeof(AbpPermissionManagementDomainSharedModule), |
||||
|
typeof(AbpSettingManagementDomainSharedModule), |
||||
|
typeof(AbpTenantManagementDomainSharedModule) |
||||
|
)] |
||||
|
public class BookStoreDomainSharedModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
Configure<VirtualFileSystemOptions>(options => |
||||
|
{ |
||||
|
options.FileSets.AddEmbedded<BookStoreDomainSharedModule>("Acme.BookStore"); |
||||
|
}); |
||||
|
|
||||
|
Configure<AbpLocalizationOptions>(options => |
||||
|
{ |
||||
|
options.Resources |
||||
|
.Add<BookStoreResource>("en") |
||||
|
.AddBaseTypes(typeof(AbpValidationResource)) |
||||
|
.AddVirtualJson("/Localization/BookStore"); |
||||
|
}); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,9 +1,9 @@ |
|||||
namespace Acme.BookStore |
namespace Acme.BookStore |
||||
{ |
{ |
||||
public enum BookType : byte |
public enum BookType |
||||
{ |
{ |
||||
Undefined, |
Undefined, |
||||
Advanture, |
Adventure, |
||||
Biography, |
Biography, |
||||
Dystopia, |
Dystopia, |
||||
Fantastic, |
Fantastic, |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "cs", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Úvod", |
||||
|
"Welcome": "Vítejte", |
||||
|
"LongWelcomeMessage": "Vítejte v aplikaci. Toto je startovací projekt založený na ABP frameworku. Pro více informací, navštivte abp.io." |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "tr", |
||||
|
"texts": { |
||||
|
"Menu:Home": "Ana sayfa", |
||||
|
"Welcome": "Hoşgeldiniz", |
||||
|
"LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz." |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,8 @@ |
|||||
|
{ |
||||
|
"culture": "zh-Hans", |
||||
|
"texts": { |
||||
|
"Menu:Home": "首页", |
||||
|
"Welcome": "欢迎", |
||||
|
"LongWelcomeMessage": "欢迎来到该应用程序. 这是一个基于ABP框架的启动项目. 有关更多信息, 请访问 cn.abp.io." |
||||
|
} |
||||
|
} |
||||
@ -1,6 +1,6 @@ |
|||||
using Volo.Abp.Localization; |
using Volo.Abp.Localization; |
||||
|
|
||||
namespace Acme.BookStore.Localization.BookStore |
namespace Acme.BookStore.Localization |
||||
{ |
{ |
||||
[LocalizationResourceName("BookStore")] |
[LocalizationResourceName("BookStore")] |
||||
public class BookStoreResource |
public class BookStoreResource |
||||
@ -0,0 +1,11 @@ |
|||||
|
namespace Acme.BookStore.MultiTenancy |
||||
|
{ |
||||
|
public static class MultiTenancyConsts |
||||
|
{ |
||||
|
/* Enable/disable multi-tenancy easily in a single point. |
||||
|
* If you will never need to multi-tenancy, you can remove |
||||
|
* related modules and code parts, including this file. |
||||
|
*/ |
||||
|
public const bool IsEnabled = true; |
||||
|
} |
||||
|
} |
||||
@ -1,25 +1,27 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
<Import Project="..\..\common.props" /> |
<Import Project="..\..\common.props" /> |
||||
|
|
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>netcoreapp2.2</TargetFramework> |
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
<RootNamespace>Acme.BookStore</RootNamespace> |
<RootNamespace>Acme.BookStore</RootNamespace> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
|
|
||||
<ItemGroup> |
<ItemGroup> |
||||
|
<ProjectReference Include="..\Acme.BookStore.Domain.Shared\Acme.BookStore.Domain.Shared.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.2.0" /> |
||||
<PackageReference Include="Volo.Abp.Identity.Domain" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.Identity.Domain" Version="0.17.0.0" /> |
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.IdentityServer.Domain" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.IdentityServer" Version="0.17.0.0" /> |
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="0.17.0.0" /> |
||||
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="0.17.0.0" /> |
||||
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="0.17.0.0" /> |
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="0.17.0.0" /> |
||||
<PackageReference Include="Volo.Abp.Auditing" Version="0.17.0.0" /> |
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="0.17.0.0" /> |
||||
<PackageReference Include="Microsoft.AspNetCore.Mvc.DataAnnotations" Version="2.2.0" /> |
|
||||
</ItemGroup> |
|
||||
|
|
||||
<ItemGroup> |
|
||||
<EmbeddedResource Include="Localization\BookStore\*.json" /> |
|
||||
</ItemGroup> |
</ItemGroup> |
||||
|
|
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,39 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.Extensions.Logging; |
||||
|
using Microsoft.Extensions.Logging.Abstractions; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Acme.BookStore.Data |
||||
|
{ |
||||
|
public class BookStoreDbMigrationService : ITransientDependency |
||||
|
{ |
||||
|
public ILogger<BookStoreDbMigrationService> Logger { get; set; } |
||||
|
|
||||
|
private readonly IDataSeeder _dataSeeder; |
||||
|
private readonly IBookStoreDbSchemaMigrator _dbSchemaMigrator; |
||||
|
|
||||
|
public BookStoreDbMigrationService( |
||||
|
IDataSeeder dataSeeder, |
||||
|
IBookStoreDbSchemaMigrator dbSchemaMigrator) |
||||
|
{ |
||||
|
_dataSeeder = dataSeeder; |
||||
|
_dbSchemaMigrator = dbSchemaMigrator; |
||||
|
|
||||
|
Logger = NullLogger<BookStoreDbMigrationService>.Instance; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
Logger.LogInformation("Started database migrations..."); |
||||
|
|
||||
|
Logger.LogInformation("Migrating database schema..."); |
||||
|
await _dbSchemaMigrator.MigrateAsync(); |
||||
|
|
||||
|
Logger.LogInformation("Executing database seed..."); |
||||
|
await _dataSeeder.SeedAsync(); |
||||
|
|
||||
|
Logger.LogInformation("Successfully completed database migrations."); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,9 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Acme.BookStore.Data |
||||
|
{ |
||||
|
public interface IBookStoreDbSchemaMigrator |
||||
|
{ |
||||
|
Task MigrateAsync(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,16 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Acme.BookStore.Data |
||||
|
{ |
||||
|
/* This is used if database provider does't define |
||||
|
* IBookStoreDbSchemaMigrator implementation. |
||||
|
*/ |
||||
|
public class NullBookStoreDbSchemaMigrator : IBookStoreDbSchemaMigrator, ITransientDependency |
||||
|
{ |
||||
|
public Task MigrateAsync() |
||||
|
{ |
||||
|
return Task.CompletedTask; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,222 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Authorization.Permissions; |
||||
|
using Volo.Abp.Configuration; |
||||
|
using Volo.Abp.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
using Volo.Abp.Guids; |
||||
|
using Volo.Abp.IdentityServer.ApiResources; |
||||
|
using Volo.Abp.IdentityServer.Clients; |
||||
|
using Volo.Abp.IdentityServer.IdentityResources; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.Uow; |
||||
|
|
||||
|
namespace Acme.BookStore.IdentityServer |
||||
|
{ |
||||
|
public class IdentityServerDataSeedContributor : IDataSeedContributor, ITransientDependency |
||||
|
{ |
||||
|
private readonly IApiResourceRepository _apiResourceRepository; |
||||
|
private readonly IClientRepository _clientRepository; |
||||
|
private readonly IIdentityResourceDataSeeder _identityResourceDataSeeder; |
||||
|
private readonly IGuidGenerator _guidGenerator; |
||||
|
private readonly IPermissionDataSeeder _permissionDataSeeder; |
||||
|
private readonly IConfigurationAccessor _configurationAccessor; |
||||
|
|
||||
|
public IdentityServerDataSeedContributor( |
||||
|
IClientRepository clientRepository, |
||||
|
IApiResourceRepository apiResourceRepository, |
||||
|
IIdentityResourceDataSeeder identityResourceDataSeeder, |
||||
|
IGuidGenerator guidGenerator, |
||||
|
IPermissionDataSeeder permissionDataSeeder, |
||||
|
IConfigurationAccessor configurationAccessor) |
||||
|
{ |
||||
|
_clientRepository = clientRepository; |
||||
|
_apiResourceRepository = apiResourceRepository; |
||||
|
_identityResourceDataSeeder = identityResourceDataSeeder; |
||||
|
_guidGenerator = guidGenerator; |
||||
|
_permissionDataSeeder = permissionDataSeeder; |
||||
|
_configurationAccessor = configurationAccessor; |
||||
|
} |
||||
|
|
||||
|
[UnitOfWork] |
||||
|
public virtual async Task SeedAsync(DataSeedContext context) |
||||
|
{ |
||||
|
await _identityResourceDataSeeder.CreateStandardResourcesAsync(); |
||||
|
await CreateApiResourcesAsync(); |
||||
|
await CreateClientsAsync(); |
||||
|
} |
||||
|
|
||||
|
private async Task CreateApiResourcesAsync() |
||||
|
{ |
||||
|
var commonApiUserClaims = new[] |
||||
|
{ |
||||
|
"email", |
||||
|
"email_verified", |
||||
|
"name", |
||||
|
"phone_number", |
||||
|
"phone_number_verified", |
||||
|
"role" |
||||
|
}; |
||||
|
|
||||
|
await CreateApiResourceAsync("BookStore", commonApiUserClaims); |
||||
|
} |
||||
|
|
||||
|
private async Task<ApiResource> CreateApiResourceAsync(string name, IEnumerable<string> claims) |
||||
|
{ |
||||
|
var apiResource = await _apiResourceRepository.FindByNameAsync(name); |
||||
|
if (apiResource == null) |
||||
|
{ |
||||
|
apiResource = await _apiResourceRepository.InsertAsync( |
||||
|
new ApiResource( |
||||
|
_guidGenerator.Create(), |
||||
|
name, |
||||
|
name + " API" |
||||
|
), |
||||
|
autoSave: true |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
foreach (var claim in claims) |
||||
|
{ |
||||
|
if (apiResource.FindClaim(claim) == null) |
||||
|
{ |
||||
|
apiResource.AddUserClaim(claim); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return await _apiResourceRepository.UpdateAsync(apiResource); |
||||
|
} |
||||
|
|
||||
|
private async Task CreateClientsAsync() |
||||
|
{ |
||||
|
const string commonSecret = "E5Xd4yMqjP5kjWFKrYgySBju6JVfCzMyFp7n2QmMrME="; |
||||
|
|
||||
|
var commonScopes = new[] |
||||
|
{ |
||||
|
"email", |
||||
|
"openid", |
||||
|
"profile", |
||||
|
"role", |
||||
|
"phone", |
||||
|
"address", |
||||
|
"BookStore" |
||||
|
}; |
||||
|
|
||||
|
var configurationSection = _configurationAccessor.Configuration.GetSection("IdentityServer:Clients"); |
||||
|
|
||||
|
//Web Client
|
||||
|
var webClientId = configurationSection["BookStore_Web:ClientId"]; |
||||
|
if (!webClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
var webClientRootUrl = configurationSection["BookStore_Web:RootUrl"].EnsureEndsWith('/'); |
||||
|
|
||||
|
/* BookStore_Web client is only needed if you created a tiered |
||||
|
* solution. Otherwise, you can delete this client. */ |
||||
|
|
||||
|
await CreateClientAsync( |
||||
|
webClientId, |
||||
|
commonScopes, |
||||
|
new[] { "hybrid" }, |
||||
|
commonSecret, |
||||
|
redirectUri: $"{webClientRootUrl}signin-oidc", |
||||
|
postLogoutRedirectUri: $"{webClientRootUrl}signout-callback-oidc" |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
//Console Test Client
|
||||
|
var consoleClientId = configurationSection["BookStore_ConsoleTestApp:ClientId"]; |
||||
|
if (!consoleClientId.IsNullOrWhiteSpace()) |
||||
|
{ |
||||
|
await CreateClientAsync( |
||||
|
consoleClientId, |
||||
|
commonScopes, |
||||
|
new[] { "password", "client_credentials" }, |
||||
|
commonSecret |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private async Task<Client> CreateClientAsync( |
||||
|
string name, |
||||
|
IEnumerable<string> scopes, |
||||
|
IEnumerable<string> grantTypes, |
||||
|
string secret, |
||||
|
string redirectUri = null, |
||||
|
string postLogoutRedirectUri = null, |
||||
|
IEnumerable<string> permissions = null) |
||||
|
{ |
||||
|
var client = await _clientRepository.FindByCliendIdAsync(name); |
||||
|
if (client == null) |
||||
|
{ |
||||
|
client = await _clientRepository.InsertAsync( |
||||
|
new Client( |
||||
|
_guidGenerator.Create(), |
||||
|
name |
||||
|
) |
||||
|
{ |
||||
|
ClientName = name, |
||||
|
ProtocolType = "oidc", |
||||
|
Description = name, |
||||
|
AlwaysIncludeUserClaimsInIdToken = true, |
||||
|
AllowOfflineAccess = true, |
||||
|
AbsoluteRefreshTokenLifetime = 31536000, //365 days
|
||||
|
AccessTokenLifetime = 31536000, //365 days
|
||||
|
AuthorizationCodeLifetime = 300, |
||||
|
IdentityTokenLifetime = 300, |
||||
|
RequireConsent = false |
||||
|
}, |
||||
|
autoSave: true |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
foreach (var scope in scopes) |
||||
|
{ |
||||
|
if (client.FindScope(scope) == null) |
||||
|
{ |
||||
|
client.AddScope(scope); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
foreach (var grantType in grantTypes) |
||||
|
{ |
||||
|
if (client.FindGrantType(grantType) == null) |
||||
|
{ |
||||
|
client.AddGrantType(grantType); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (client.FindSecret(secret) == null) |
||||
|
{ |
||||
|
client.AddSecret(secret); |
||||
|
} |
||||
|
|
||||
|
if (redirectUri != null) |
||||
|
{ |
||||
|
if (client.FindRedirectUri(redirectUri) == null) |
||||
|
{ |
||||
|
client.AddRedirectUri(redirectUri); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (postLogoutRedirectUri != null) |
||||
|
{ |
||||
|
if (client.FindPostLogoutRedirectUri(postLogoutRedirectUri) == null) |
||||
|
{ |
||||
|
client.AddPostLogoutRedirectUri(postLogoutRedirectUri); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
if (permissions != null) |
||||
|
{ |
||||
|
await _permissionDataSeeder.SeedAsync( |
||||
|
ClientPermissionValueProvider.ProviderName, |
||||
|
name, |
||||
|
permissions |
||||
|
); |
||||
|
} |
||||
|
|
||||
|
return await _clientRepository.UpdateAsync(client); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,20 +0,0 @@ |
|||||
{ |
|
||||
"culture": "cs", |
|
||||
"texts": { |
|
||||
"Menu:Home": "Úvod", |
|
||||
"Welcome": "Vítejte", |
|
||||
"LongWelcomeMessage": "Vítejte v aplikaci. Toto je startovací projekt založený na ABP frameworku. Pro více informací, navštivte abp.io.", |
|
||||
"Menu:BookStore": "Knihkupectví", |
|
||||
"Menu:Books": "Knihy", |
|
||||
"Name": "Název", |
|
||||
"Type": "Typ", |
|
||||
"PublishDate": "Publikováno", |
|
||||
"Price": "Cena", |
|
||||
"CreationTime": "Vytvořeno", |
|
||||
"NewBook": "Nová kniha", |
|
||||
"Books": "Knihy", |
|
||||
"Update": "Aktualizovat", |
|
||||
"BookDeletionConfirmationMessage": "Opravdu chcete smazat tuto knihu: {0}", |
|
||||
"SuccessfullyDeleted": "Úspěšně smazáno." |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
{ |
|
||||
"culture": "tr", |
|
||||
"texts": { |
|
||||
"Menu:Home": "Ana sayfa", |
|
||||
"Welcome": "Hoşgeldiniz", |
|
||||
"LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz.", |
|
||||
"Menu:BookStore": "Kitap Mağazası", |
|
||||
"Menu:Books": "Kitaplar", |
|
||||
"Name": "İsim", |
|
||||
"Type": "Tür", |
|
||||
"PublishDate": "Yayınlanma Tarihi", |
|
||||
"Price": "Fiyat", |
|
||||
"CreationTime": "Oluşturulma zamanı", |
|
||||
"NewBook": "Yeni kitap", |
|
||||
"Books": "Kitaplar", |
|
||||
"Update": "Güncelle", |
|
||||
"BookDeletionConfirmationMessage": "Bu kitabı silmek istediğinize emin misiniz: {0}", |
|
||||
"SuccessfullyDeleted": "Başarıyla silindi." |
|
||||
} |
|
||||
} |
|
||||
@ -1,20 +0,0 @@ |
|||||
{ |
|
||||
"culture": "zh-Hans", |
|
||||
"texts": { |
|
||||
"Menu:Home": "首页", |
|
||||
"Welcome": "欢迎", |
|
||||
"LongWelcomeMessage": "欢迎来到该应用程序. 这是一个基于ABP框架的启动项目. 有关更多信息, 请访问 cn.abp.io.", |
|
||||
"Menu:BookStore": "图书商店", |
|
||||
"Menu:Books": "图书", |
|
||||
"Name": "名称", |
|
||||
"Type": "类型", |
|
||||
"PublishDate": "出版时间", |
|
||||
"Price": "价格", |
|
||||
"CreationTime": "添加时间", |
|
||||
"NewBook": "新书籍", |
|
||||
"Books": "图书", |
|
||||
"Update": "更新", |
|
||||
"BookDeletionConfirmationMessage": "你确定删除书箱: {0} 吗", |
|
||||
"SuccessfullyDeleted": "删除成功." |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,16 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Acme.BookStore.EntityFrameworkCore |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BookStoreEntityFrameworkCoreModule) |
||||
|
)] |
||||
|
public class BookStoreEntityFrameworkCoreDbMigrationsModule : AbpModule |
||||
|
{ |
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddAbpDbContext<BookStoreMigrationsDbContext>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,24 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
using Microsoft.EntityFrameworkCore; |
||||
|
using Acme.BookStore.Data; |
||||
|
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
|
namespace Acme.BookStore.EntityFrameworkCore |
||||
|
{ |
||||
|
[Dependency(ReplaceServices = true)] |
||||
|
public class EntityFrameworkCoreBookStoreDbSchemaMigrator |
||||
|
: IBookStoreDbSchemaMigrator, ITransientDependency |
||||
|
{ |
||||
|
private readonly BookStoreMigrationsDbContext _dbContext; |
||||
|
|
||||
|
public EntityFrameworkCoreBookStoreDbSchemaMigrator(BookStoreMigrationsDbContext dbContext) |
||||
|
{ |
||||
|
_dbContext = dbContext; |
||||
|
} |
||||
|
|
||||
|
public async Task MigrateAsync() |
||||
|
{ |
||||
|
await _dbContext.Database.MigrateAsync(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<RootNamespace>Acme.BookStore</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Acme.BookStore.Application.Contracts\Acme.BookStore.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi.Client" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi.Client" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi.Client" Version="0.17.0.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,29 @@ |
|||||
|
using Microsoft.Extensions.DependencyInjection; |
||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BookStoreApplicationContractsModule), |
||||
|
typeof(AbpIdentityHttpApiClientModule), |
||||
|
typeof(AbpPermissionManagementHttpApiClientModule), |
||||
|
typeof(AbpTenantManagementHttpApiClientModule), |
||||
|
typeof(AbpFeatureManagementHttpApiClientModule) |
||||
|
)] |
||||
|
public class BookStoreHttpApiClientModule : AbpModule |
||||
|
{ |
||||
|
public const string RemoteServiceName = "Default"; |
||||
|
|
||||
|
public override void ConfigureServices(ServiceConfigurationContext context) |
||||
|
{ |
||||
|
context.Services.AddHttpClientProxies( |
||||
|
typeof(BookStoreApplicationContractsModule).Assembly, |
||||
|
RemoteServiceName |
||||
|
); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,21 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
|
<RootNamespace>Acme.BookStore</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Acme.BookStore.Application.Contracts\Acme.BookStore.Application.Contracts.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi" Version="0.17.0.0" /> |
||||
|
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" Version="0.17.0.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,20 @@ |
|||||
|
using Volo.Abp.FeatureManagement; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.PermissionManagement.HttpApi; |
||||
|
using Volo.Abp.TenantManagement; |
||||
|
|
||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BookStoreApplicationContractsModule), |
||||
|
typeof(AbpIdentityHttpApiModule), |
||||
|
typeof(AbpPermissionManagementHttpApiModule), |
||||
|
typeof(AbpTenantManagementHttpApiModule), |
||||
|
typeof(AbpFeatureManagementHttpApiModule) |
||||
|
)] |
||||
|
public class BookStoreHttpApiModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Acme.BookStore.Localization; |
||||
|
using Volo.Abp.AspNetCore.Mvc; |
||||
|
|
||||
|
namespace Acme.BookStore.Controllers |
||||
|
{ |
||||
|
public abstract class BookStoreController : AbpController |
||||
|
{ |
||||
|
protected BookStoreController() |
||||
|
{ |
||||
|
//LocalizationResource = typeof(BookStoreResource);
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,28 @@ |
|||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Acme.BookStore.Models.Test; |
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Acme.BookStore.Controllers |
||||
|
{ |
||||
|
[Route("api/test")] |
||||
|
public class TestController : BookStoreController |
||||
|
{ |
||||
|
public TestController() |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
[HttpGet] |
||||
|
[Route("")] |
||||
|
public async Task<List<TestModel>> GetAsync() |
||||
|
{ |
||||
|
return new List<TestModel> |
||||
|
{ |
||||
|
new TestModel {Name = "John", BirthDate = new DateTime(1942, 11, 18)}, |
||||
|
new TestModel {Name = "Adams", BirthDate = new DateTime(1997, 05, 24)} |
||||
|
}; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Acme.BookStore.Models.Test |
||||
|
{ |
||||
|
public class TestModel |
||||
|
{ |
||||
|
public string Name { get; set; } |
||||
|
|
||||
|
public DateTime BirthDate { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -1,7 +1,7 @@ |
|||||
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; |
using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Components; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
|
|
||||
namespace Acme.BookStore.Branding |
namespace Acme.BookStore.Web |
||||
{ |
{ |
||||
[Dependency(ReplaceServices = true)] |
[Dependency(ReplaceServices = true)] |
||||
public class BookStoreBrandingProvider : DefaultBrandingProvider |
public class BookStoreBrandingProvider : DefaultBrandingProvider |
||||
@ -1,12 +1,12 @@ |
|||||
using AutoMapper; |
using AutoMapper; |
||||
|
|
||||
namespace Acme.BookStore |
namespace Acme.BookStore.Web |
||||
{ |
{ |
||||
public class BookStoreWebAutoMapperProfile : Profile |
public class BookStoreWebAutoMapperProfile : Profile |
||||
{ |
{ |
||||
public BookStoreWebAutoMapperProfile() |
public BookStoreWebAutoMapperProfile() |
||||
{ |
{ |
||||
//Configure your AutoMapper mapping configuration here...
|
CreateMap<BookDto, CreateUpdateBookDto>(); |
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,16 +1,12 @@ |
|||||
using System; |
using Microsoft.AspNetCore.Mvc.RazorPages; |
||||
using System.Collections.Generic; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.AspNetCore.Mvc; |
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages; |
|
||||
|
|
||||
namespace Acme.BookStore.Pages.Books |
namespace Acme.BookStore.Web.Pages.Books |
||||
{ |
{ |
||||
public class IndexModel : PageModel |
public class IndexModel : PageModel |
||||
{ |
{ |
||||
public void OnGet() |
public void OnGet() |
||||
{ |
{ |
||||
|
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
body { |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
$(function () { |
||||
|
abp.log.debug('Index.js initialized!'); |
||||
|
}); |
||||
@ -1,3 +1,4 @@ |
|||||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers |
||||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI |
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI |
||||
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bootstrap |
||||
|
@addTagHelper *, Volo.Abp.AspNetCore.Mvc.UI.Bundling |
||||
@ -0,0 +1,2 @@ |
|||||
|
{ |
||||
|
} |
||||
@ -1,5 +1,16 @@ |
|||||
{ |
{ |
||||
|
"AppSelfUrl": "https://localhost:44361", |
||||
"ConnectionStrings": { |
"ConnectionStrings": { |
||||
"Default": "Server=localhost;Database=BookStore;Trusted_Connection=True;MultipleActiveResultSets=true" |
"Default": "Server=localhost;Database=BookStore;Trusted_Connection=True;MultipleActiveResultSets=true" |
||||
|
}, |
||||
|
"AuthServer": { |
||||
|
"Authority": "https://localhost:44361" |
||||
|
}, |
||||
|
"IdentityServer": { |
||||
|
"Clients": { |
||||
|
"BookStore_ConsoleTestApp": { |
||||
|
"ClientId": "BookStore_ConsoleTestApp" |
||||
|
} |
||||
|
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,6 +0,0 @@ |
|||||
[ |
|
||||
{ |
|
||||
"outputFile": "wwwroot/pages/index.css", |
|
||||
"inputFile": "wwwroot/pages/index.scss" |
|
||||
} |
|
||||
] |
|
||||
@ -1,49 +0,0 @@ |
|||||
{ |
|
||||
"compilers": { |
|
||||
"less": { |
|
||||
"autoPrefix": "", |
|
||||
"cssComb": "none", |
|
||||
"ieCompat": true, |
|
||||
"strictMath": false, |
|
||||
"strictUnits": false, |
|
||||
"relativeUrls": true, |
|
||||
"rootPath": "", |
|
||||
"sourceMapRoot": "", |
|
||||
"sourceMapBasePath": "", |
|
||||
"sourceMap": false |
|
||||
}, |
|
||||
"sass": { |
|
||||
"includePath": "", |
|
||||
"indentType": "space", |
|
||||
"indentWidth": 2, |
|
||||
"outputStyle": "nested", |
|
||||
"Precision": 5, |
|
||||
"relativeUrls": true, |
|
||||
"sourceMapRoot": "", |
|
||||
"sourceMap": false |
|
||||
}, |
|
||||
"stylus": { |
|
||||
"sourceMap": false |
|
||||
}, |
|
||||
"babel": { |
|
||||
"sourceMap": false |
|
||||
}, |
|
||||
"coffeescript": { |
|
||||
"bare": false, |
|
||||
"runtimeMode": "node", |
|
||||
"sourceMap": false |
|
||||
} |
|
||||
}, |
|
||||
"minifiers": { |
|
||||
"css": { |
|
||||
"enabled": true, |
|
||||
"termSemicolons": true, |
|
||||
"gzip": false |
|
||||
}, |
|
||||
"javascript": { |
|
||||
"enabled": true, |
|
||||
"termSemicolons": true, |
|
||||
"gzip": false |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1 @@ |
|||||
|
{"KeyId":"ac0d2edf3c04d13cd95cc41b9b33ab03","Parameters":{"D":"FFymEWbX3XBT5YnTngOKwtz3XKsyaQbyDvvw9jbmkdvLKUmrb1hkmylqVYwU/3G1u79rrD8AZXJDoYVLegyZymK/iNeePMLI4i5vScF7PdQXn/g6CvQ8j3J60YYyfDWuxjBH8nCEUIfQIv14BpcH6CWi1BVZUbnbWcpe2ji8D5I3FHOZpvksQztst5eE836ODdN9jgk35kgrdUQ14MEFHA6m6fAzvFI1csFxD3Kwej4rI8RYZ0WYLkndz9ID88+v9VxqI8+wN6wR6tIOR510uT1FI5wONBVBUzgeZ6cCEpg0jC9tgqcP03gMDpmE7vKp34ExxH/iOWyhQ0gAxHOVlQ==","DP":"qSQfNZvEkepgY12d+uwTbRoOp+0g1CBiMU9kqyoIB56hAUnzENSCDzunjLRrvDLFPgXiUcoccskyVRnKKOGPOqPE6VjgzBrdLgA/hBf8hPg0GnTVoPyLxR9G6GsGUKsAYVn8G7cnK5wXzK4jCjsflkfxCzFfdASJ/+sa5QPWZMM=","DQ":"u+56T1+rhMvlurid9kBS2Ypfm4vOiNAXLD9kGz2wx8Ob0yYlWo55kn11qPs6Ej9bnQIY3N+TY2tXMamfhAhntoHaKrFjOpCmlHZ0GAeQOJVuWSlFvu/NBoxfjZzcUCNua22oJjy++wSdkkLLGEqau62byaQoSSqUxUzwL36RexM=","Exponent":"AQAB","InverseQ":"E+uq9g6D5LjUk+M7gtt0srnT8duwu8P83AgFqjtGOnSCy71omSboxb4zC9bGq/WaEFauFBwqxbkXwFyXuYNfIelfmSERulU9jgf0+KH6QmFdtjrJ5UO7VArqET1WUquwiDvOyO8udCxi8RRAiM5G3dTzIs5JTalGhlKEZSAgPtQ=","Modulus":"rgHACxzqvuE72RF/NdDTLsIEy3F/n6P4lkgrER60FU8uRNwSmAMRxvxYOaE3Ot/krRYcw2+MP8ewR1VBXywXVT1zuACA3SacMHJYmZQ2UkuwsD9bmpjvqoMhR/hjsI74jTzKpclHtEu7D7WYDZaIPAEIs/8+5H/z1mXVfgACaeaQt3C0OhwXSOPPDP71VKGfoFucXYED1keZ0PKxYAlhiHOe7cnSlfJseujwD2Rhyq8mUhe6aEMTYBjuruWgpfvnSOARAqu5vwzK35KpAirHwa1DJSZyanNMFdlLkVNKWUKEqd6PwRneiHacmaaDF6oQQstuSbf9cuJeSMbKh7WVQQ==","P":"0CJDit2NHk0Z1bN5ZVIYZRUYbrAI2bEOafAKqfffcA/Os7yXsY14Ye4pSpDxfdZGcPGRL04HPkJsogFtyI7k4ujrvsC66I5cg45+BhBMM0zyLJ7LZkD2HGwX2+a/xrXhhIIOnGWWy2zzW3dkayRhi1bR9krfTA5uBw1LX9qZ3Yc=","Q":"1gZITAaB+r0+PgOfyDCeVzSnTyQuKSkgbUkIgQP9jQZa6edrbAXogdJipxmUTrW7JaxifG1z9ubK+TOqhjZHqT4gd8U8Bh7jCBizZNVe60pez1OtNGpEOW2N+ZrXBSMNcV8PFaMg/B+fcaX+i7NWpTqmztR/V0DGXmD+XosuaPc="}} |
||||
@ -1 +0,0 @@ |
|||||
|
|
||||
@ -1 +0,0 @@ |
|||||
|
|
||||
@ -1,3 +0,0 @@ |
|||||
body{ |
|
||||
|
|
||||
} |
|
||||
@ -1,12 +1,7 @@ |
|||||
using Volo.Abp; |
namespace Acme.BookStore |
||||
|
|
||||
namespace Acme.BookStore |
|
||||
{ |
{ |
||||
public abstract class BookStoreApplicationTestBase : AbpIntegratedTest<BookStoreApplicationTestModule> |
public abstract class BookStoreApplicationTestBase : BookStoreTestBase<BookStoreApplicationTestModule> |
||||
{ |
{ |
||||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) |
|
||||
{ |
|
||||
options.UseAutofac(); |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -1,78 +1,13 @@ |
|||||
using Microsoft.Data.Sqlite; |
using Volo.Abp.Modularity; |
||||
using Microsoft.EntityFrameworkCore; |
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure; |
|
||||
using Microsoft.EntityFrameworkCore.Storage; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Acme.BookStore.EntityFrameworkCore; |
|
||||
using Volo.Abp; |
|
||||
using Volo.Abp.Autofac; |
|
||||
using Volo.Abp.EntityFrameworkCore; |
|
||||
using Volo.Abp.Modularity; |
|
||||
|
|
||||
namespace Acme.BookStore |
namespace Acme.BookStore |
||||
{ |
{ |
||||
[DependsOn( |
[DependsOn( |
||||
typeof(BookStoreApplicationModule), |
typeof(BookStoreApplicationModule), |
||||
typeof(BookStoreEntityFrameworkCoreModule), |
typeof(BookStoreDomainTestModule) |
||||
typeof(AbpAutofacModule), |
|
||||
typeof(AbpTestBaseModule) |
|
||||
)] |
)] |
||||
public class BookStoreApplicationTestModule : AbpModule |
public class BookStoreApplicationTestModule : AbpModule |
||||
{ |
{ |
||||
private SqliteConnection _sqliteConnection; |
|
||||
|
|
||||
public override void ConfigureServices(ServiceConfigurationContext context) |
|
||||
{ |
|
||||
context.Services.AddAlwaysAllowAuthorization(); |
|
||||
|
|
||||
ConfigureInMemorySqlite(context.Services); |
|
||||
} |
|
||||
|
|
||||
private void ConfigureInMemorySqlite(IServiceCollection services) |
|
||||
{ |
|
||||
_sqliteConnection = CreateDatabaseAndGetConnection(); |
|
||||
|
|
||||
services.Configure<AbpDbContextOptions>(options => |
|
||||
{ |
|
||||
options.Configure(context => { context.DbContextOptions.UseSqlite(_sqliteConnection); }); |
|
||||
}); |
|
||||
} |
|
||||
|
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context) |
|
||||
{ |
|
||||
SeedTestData(context); |
|
||||
} |
|
||||
|
|
||||
public override void OnApplicationShutdown(ApplicationShutdownContext context) |
|
||||
{ |
|
||||
_sqliteConnection.Dispose(); |
|
||||
} |
|
||||
|
|
||||
private static SqliteConnection CreateDatabaseAndGetConnection() |
|
||||
{ |
|
||||
var connection = new SqliteConnection("Data Source=:memory:"); |
|
||||
connection.Open(); |
|
||||
|
|
||||
var options = new DbContextOptionsBuilder<BookStoreMigrationsDbContext>() |
|
||||
.UseSqlite(connection) |
|
||||
.Options; |
|
||||
|
|
||||
using (var context = new BookStoreMigrationsDbContext(options)) |
|
||||
{ |
|
||||
context.GetService<IRelationalDatabaseCreator>().CreateTables(); |
|
||||
} |
|
||||
|
|
||||
return connection; |
|
||||
} |
|
||||
|
|
||||
private static void SeedTestData(ApplicationInitializationContext context) |
|
||||
{ |
|
||||
using (var scope = context.ServiceProvider.CreateScope()) |
|
||||
{ |
|
||||
scope.ServiceProvider |
|
||||
.GetRequiredService<BookStoreTestDataBuilder>() |
|
||||
.Build(); |
|
||||
} |
|
||||
} |
|
||||
} |
} |
||||
} |
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
using Shouldly; |
||||
|
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Identity; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Acme.BookStore.Samples |
||||
|
{ |
||||
|
/* This is just an example test class. |
||||
|
* Normally, you don't test code of the modules you are using |
||||
|
* (like IIdentityUserAppService here). |
||||
|
* Only test your own application services. |
||||
|
*/ |
||||
|
public class SampleAppServiceTests : BookStoreApplicationTestBase |
||||
|
{ |
||||
|
private readonly IIdentityUserAppService _userAppService; |
||||
|
|
||||
|
public SampleAppServiceTests() |
||||
|
{ |
||||
|
_userAppService = GetRequiredService<IIdentityUserAppService>(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task Initial_Data_Should_Contain_Admin_User() |
||||
|
{ |
||||
|
//Act
|
||||
|
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); |
||||
|
|
||||
|
//Assert
|
||||
|
result.TotalCount.ShouldBeGreaterThan(0); |
||||
|
result.Items.ShouldContain(u => u.UserName == "admin"); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,59 +0,0 @@ |
|||||
using System; |
|
||||
using System.Linq; |
|
||||
using System.Threading.Tasks; |
|
||||
using Microsoft.EntityFrameworkCore; |
|
||||
using Microsoft.Extensions.DependencyInjection; |
|
||||
using Acme.BookStore.Users; |
|
||||
using Shouldly; |
|
||||
using Volo.Abp.Domain.Repositories; |
|
||||
using Volo.Abp.Identity; |
|
||||
using Volo.Abp.Uow; |
|
||||
using Xunit; |
|
||||
|
|
||||
namespace Acme.BookStore.Samples |
|
||||
{ |
|
||||
public class SampleTests : BookStoreApplicationTestBase |
|
||||
{ |
|
||||
private readonly IIdentityUserAppService _userAppService; |
|
||||
private readonly IRepository<AppUser, Guid> _appUserRepository; |
|
||||
private readonly IUnitOfWorkManager _unitOfWorkManager; |
|
||||
|
|
||||
public SampleTests() |
|
||||
{ |
|
||||
_userAppService = ServiceProvider.GetRequiredService<IIdentityUserAppService>(); |
|
||||
_appUserRepository = ServiceProvider.GetRequiredService<IRepository<AppUser, Guid>>(); |
|
||||
_unitOfWorkManager = ServiceProvider.GetRequiredService<IUnitOfWorkManager>(); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task Initial_Data_Should_Contain_Admin_User() |
|
||||
{ |
|
||||
//Act
|
|
||||
var result = await _userAppService.GetListAsync(new GetIdentityUsersInput()); |
|
||||
|
|
||||
//Assert
|
|
||||
result.TotalCount.ShouldBeGreaterThan(0); |
|
||||
result.Items.ShouldContain(u => u.UserName == "admin"); |
|
||||
} |
|
||||
|
|
||||
[Fact] |
|
||||
public async Task Should_Query_AppUser() |
|
||||
{ |
|
||||
/* Need to manually start Unit Of Work because |
|
||||
* FirstOrDefaultAsync should be executed while db connection / context is available. |
|
||||
*/ |
|
||||
using (var uow = _unitOfWorkManager.Begin()) |
|
||||
{ |
|
||||
//Act
|
|
||||
var adminUser = await _appUserRepository |
|
||||
.Where(u => u.UserName == "admin") |
|
||||
.FirstOrDefaultAsync(); |
|
||||
|
|
||||
//Assert
|
|
||||
adminUser.ShouldNotBeNull(); |
|
||||
|
|
||||
await uow.CompleteAsync(); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,18 @@ |
|||||
|
<Project Sdk="Microsoft.NET.Sdk"> |
||||
|
|
||||
|
<Import Project="..\..\common.props" /> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<TargetFramework>netcoreapp2.2</TargetFramework> |
||||
|
<RootNamespace>Acme.BookStore</RootNamespace> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="..\Acme.BookStore.EntityFrameworkCore.Tests\Acme.BookStore.EntityFrameworkCore.Tests.csproj" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.1.0" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
</Project> |
||||
@ -0,0 +1,7 @@ |
|||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
public abstract class BookStoreDomainTestBase : BookStoreTestBase<BookStoreDomainTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,13 @@ |
|||||
|
using Acme.BookStore.EntityFrameworkCore; |
||||
|
using Volo.Abp.Modularity; |
||||
|
|
||||
|
namespace Acme.BookStore |
||||
|
{ |
||||
|
[DependsOn( |
||||
|
typeof(BookStoreEntityFrameworkCoreTestModule) |
||||
|
)] |
||||
|
public class BookStoreDomainTestModule : AbpModule |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue