chore 优化代码
This commit is contained in:
@ -25,4 +25,4 @@ public class PaymentApplicationContractsModule : AbpModule
|
||||
{
|
||||
PaymentDtoExtensions.Configure();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,28 +1,26 @@
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentDtoExtensions
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
private static readonly OneTimeRunner OneTimeRunner = new();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
OneTimeRunner.Run(() =>
|
||||
{
|
||||
/* You can add extension properties to DTOs
|
||||
* defined in the depended modules.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ObjectExtensionManager.Instance
|
||||
* .AddOrUpdateProperty<IdentityRoleDto, string>("Title");
|
||||
*
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Object-Extensions
|
||||
*/
|
||||
/* You can add extension properties to DTOs
|
||||
* defined in the depended modules.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ObjectExtensionManager.Instance
|
||||
* .AddOrUpdateProperty<IdentityRoleDto, string>("Title");
|
||||
*
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Object-Extensions
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,4 +17,4 @@ public class PaymentPermissionDefinitionProvider : PermissionDefinitionProvider
|
||||
{
|
||||
return LocalizableString.Create<PaymentResource>(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,4 +6,4 @@ public static class PaymentPermissions
|
||||
|
||||
//Add your own permission names. Example:
|
||||
//public const string MyPermission1 = GroupName + ".MyPermission1";
|
||||
}
|
||||
}
|
||||
@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using KonSoft.Payment.Localization;
|
||||
using KonSoft.Payment.Localization;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
@ -14,4 +11,4 @@ public abstract class PaymentAppService : ApplicationService
|
||||
{
|
||||
LocalizationResource = typeof(PaymentResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,10 +4,4 @@ namespace KonSoft.Payment;
|
||||
|
||||
public class PaymentApplicationAutoMapperProfile : Profile
|
||||
{
|
||||
public PaymentApplicationAutoMapperProfile()
|
||||
{
|
||||
/* You can configure your AutoMapper mapping configuration here.
|
||||
* Alternatively, you can split your mapping configurations
|
||||
* into multiple profile classes for a better organization. */
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -18,14 +18,11 @@ namespace KonSoft.Payment;
|
||||
typeof(AbpTenantManagementApplicationModule),
|
||||
typeof(AbpFeatureManagementApplicationModule),
|
||||
typeof(AbpSettingManagementApplicationModule)
|
||||
)]
|
||||
)]
|
||||
public class PaymentApplicationModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpAutoMapperOptions>(options =>
|
||||
{
|
||||
options.AddMaps<PaymentApplicationModule>();
|
||||
});
|
||||
Configure<AbpAutoMapperOptions>(options => { options.AddMaps<PaymentApplicationModule>(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,2 +1,3 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.Application.Tests")]
|
||||
|
||||
[assembly: InternalsVisibleToAttribute("KonSoft.Payment.Application.Tests")]
|
||||
@ -5,5 +5,4 @@ namespace KonSoft.Payment.Localization;
|
||||
[LocalizationResourceName("Payment")]
|
||||
public class PaymentResource
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -7,4 +7,4 @@ public static class MultiTenancyConsts
|
||||
* related modules and code parts, including this file.
|
||||
*/
|
||||
public const bool IsEnabled = true;
|
||||
}
|
||||
}
|
||||
@ -3,4 +3,4 @@
|
||||
public static class PaymentDomainErrorCodes
|
||||
{
|
||||
/* You can add your business exception error codes here, as constants */
|
||||
}
|
||||
}
|
||||
@ -23,8 +23,8 @@ namespace KonSoft.Payment;
|
||||
typeof(AbpOpenIddictDomainSharedModule),
|
||||
typeof(AbpPermissionManagementDomainSharedModule),
|
||||
typeof(AbpSettingManagementDomainSharedModule),
|
||||
typeof(AbpTenantManagementDomainSharedModule)
|
||||
)]
|
||||
typeof(AbpTenantManagementDomainSharedModule)
|
||||
)]
|
||||
public class PaymentDomainSharedModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
@ -55,4 +55,4 @@ public class PaymentDomainSharedModule : AbpModule
|
||||
options.MapCodeNamespace("Payment", typeof(PaymentResource));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,19 +4,19 @@ namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentGlobalFeatureConfigurator
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
private static readonly OneTimeRunner OneTimeRunner = new();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
OneTimeRunner.Run(() =>
|
||||
{
|
||||
/* You can configure (enable/disable) global features of the used modules here.
|
||||
*
|
||||
* YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT!
|
||||
*
|
||||
* Please refer to the documentation to lear more about the Global Features System:
|
||||
* https://docs.abp.io/en/abp/latest/Global-Features
|
||||
*/
|
||||
/* You can configure (enable/disable) global features of the used modules here.
|
||||
*
|
||||
* YOU CAN SAFELY DELETE THIS CLASS AND REMOVE ITS USAGES IF YOU DON'T NEED TO IT!
|
||||
*
|
||||
* Please refer to the documentation to lear more about the Global Features System:
|
||||
* https://docs.abp.io/en/abp/latest/Global-Features
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,10 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentModuleExtensionConfigurator
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
private static readonly OneTimeRunner OneTimeRunner = new();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
@ -57,7 +54,7 @@ public static class PaymentModuleExtensionConfigurator
|
||||
//validation rules
|
||||
property.Attributes.Add(new RequiredAttribute());
|
||||
property.Attributes.Add(new StringLengthAttribute(64) {MinimumLength = 4});
|
||||
|
||||
|
||||
property.Configuration[IdentityModuleExtensionConsts.ConfigurationNames.AllowUserToEdit] = true;
|
||||
|
||||
//...other configurations for this property
|
||||
@ -70,4 +67,4 @@ public static class PaymentModuleExtensionConfigurator
|
||||
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
|
||||
*/
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,4 +5,4 @@ namespace KonSoft.Payment.Data;
|
||||
public interface IPaymentDbSchemaMigrator
|
||||
{
|
||||
Task MigrateAsync();
|
||||
}
|
||||
}
|
||||
@ -12,4 +12,4 @@ public class NullPaymentDbSchemaMigrator : IPaymentDbSchemaMigrator, ITransientD
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,12 +17,11 @@ namespace KonSoft.Payment.Data;
|
||||
|
||||
public class PaymentDbMigrationService : ITransientDependency
|
||||
{
|
||||
public ILogger<PaymentDbMigrationService> Logger { get; set; }
|
||||
private readonly ICurrentTenant _currentTenant;
|
||||
|
||||
private readonly IDataSeeder _dataSeeder;
|
||||
private readonly IEnumerable<IPaymentDbSchemaMigrator> _dbSchemaMigrators;
|
||||
private readonly ITenantRepository _tenantRepository;
|
||||
private readonly ICurrentTenant _currentTenant;
|
||||
|
||||
public PaymentDbMigrationService(
|
||||
IDataSeeder dataSeeder,
|
||||
@ -38,6 +37,8 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
Logger = NullLogger<PaymentDbMigrationService>.Instance;
|
||||
}
|
||||
|
||||
public ILogger<PaymentDbMigrationService> Logger { get; set; }
|
||||
|
||||
public async Task MigrateAsync()
|
||||
{
|
||||
var initialMigrationAdded = AddInitialMigrationIfNotExist();
|
||||
@ -52,7 +53,7 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
await MigrateDatabaseSchemaAsync();
|
||||
await SeedDataAsync();
|
||||
|
||||
Logger.LogInformation($"Successfully completed host database migrations.");
|
||||
Logger.LogInformation("Successfully completed host database migrations.");
|
||||
|
||||
var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
|
||||
|
||||
@ -101,8 +102,10 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
Logger.LogInformation($"Executing {(tenant == null ? "host" : tenant.Name + " tenant")} database seed...");
|
||||
|
||||
await _dataSeeder.SeedAsync(new DataSeedContext(tenant?.Id)
|
||||
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName, IdentityDataSeedContributor.AdminEmailDefaultValue)
|
||||
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName, IdentityDataSeedContributor.AdminPasswordDefaultValue)
|
||||
.WithProperty(IdentityDataSeedContributor.AdminEmailPropertyName,
|
||||
IdentityDataSeedContributor.AdminEmailDefaultValue)
|
||||
.WithProperty(IdentityDataSeedContributor.AdminPasswordPropertyName,
|
||||
IdentityDataSeedContributor.AdminPasswordDefaultValue)
|
||||
);
|
||||
}
|
||||
|
||||
@ -127,10 +130,8 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
AddInitialMigration();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@ -149,7 +150,8 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
private bool MigrationsFolderExists()
|
||||
{
|
||||
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
|
||||
return dbMigrationsProjectFolder != null && Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
|
||||
return dbMigrationsProjectFolder != null &&
|
||||
Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
|
||||
}
|
||||
|
||||
private void AddInitialMigration()
|
||||
@ -207,7 +209,8 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
{
|
||||
currentDirectory = Directory.GetParent(currentDirectory.FullName);
|
||||
|
||||
if (currentDirectory != null && Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
|
||||
if (currentDirectory != null &&
|
||||
Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
|
||||
{
|
||||
return currentDirectory.FullName;
|
||||
}
|
||||
@ -215,4 +218,4 @@ public class PaymentDbMigrationService : ITransientDependency
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,12 +23,12 @@ namespace KonSoft.Payment.OpenIddict;
|
||||
*/
|
||||
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
private readonly IAbpApplicationManager _applicationManager;
|
||||
private readonly IConfiguration _configuration;
|
||||
private readonly IOpenIddictApplicationRepository _openIddictApplicationRepository;
|
||||
private readonly IAbpApplicationManager _applicationManager;
|
||||
private readonly IOpenIddictScopeRepository _openIddictScopeRepository;
|
||||
private readonly IOpenIddictScopeManager _scopeManager;
|
||||
private readonly IPermissionDataSeeder _permissionDataSeeder;
|
||||
private readonly IOpenIddictScopeManager _scopeManager;
|
||||
private readonly IStringLocalizer<OpenIddictResponse> L;
|
||||
|
||||
public OpenIddictDataSeedContributor(
|
||||
@ -38,7 +38,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
IOpenIddictScopeRepository openIddictScopeRepository,
|
||||
IOpenIddictScopeManager scopeManager,
|
||||
IPermissionDataSeeder permissionDataSeeder,
|
||||
IStringLocalizer<OpenIddictResponse> l )
|
||||
IStringLocalizer<OpenIddictResponse> l)
|
||||
{
|
||||
_configuration = configuration;
|
||||
_openIddictApplicationRepository = openIddictApplicationRepository;
|
||||
@ -60,7 +60,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
{
|
||||
if (await _openIddictScopeRepository.FindByNameAsync("Payment") == null)
|
||||
{
|
||||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor {
|
||||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor
|
||||
{
|
||||
Name = "Payment", DisplayName = "Payment API", Resources = { "Payment" }
|
||||
});
|
||||
}
|
||||
@ -68,7 +69,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
|
||||
private async Task CreateApplicationsAsync()
|
||||
{
|
||||
var commonScopes = new List<string> {
|
||||
var commonScopes = new List<string>
|
||||
{
|
||||
OpenIddictConstants.Permissions.Scopes.Address,
|
||||
OpenIddictConstants.Permissions.Scopes.Email,
|
||||
OpenIddictConstants.Permissions.Scopes.Phone,
|
||||
@ -80,10 +82,6 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
var configurationSection = _configuration.GetSection("OpenIddict:Applications");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Swagger Client
|
||||
var swaggerClientId = configurationSection["Payment_Swagger:ClientId"];
|
||||
if (!swaggerClientId.IsNullOrWhiteSpace())
|
||||
@ -91,13 +89,13 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
var swaggerRootUrl = configurationSection["Payment_Swagger:RootUrl"]?.TrimEnd('/');
|
||||
|
||||
await CreateApplicationAsync(
|
||||
name: swaggerClientId!,
|
||||
type: OpenIddictConstants.ClientTypes.Public,
|
||||
consentType: OpenIddictConstants.ConsentTypes.Implicit,
|
||||
displayName: "Swagger Application",
|
||||
secret: null,
|
||||
grantTypes: [OpenIddictConstants.GrantTypes.AuthorizationCode],
|
||||
scopes: commonScopes,
|
||||
swaggerClientId!,
|
||||
OpenIddictConstants.ClientTypes.Public,
|
||||
OpenIddictConstants.ConsentTypes.Implicit,
|
||||
"Swagger Application",
|
||||
null,
|
||||
[OpenIddictConstants.GrantTypes.AuthorizationCode],
|
||||
commonScopes,
|
||||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
|
||||
clientUri: swaggerRootUrl
|
||||
);
|
||||
@ -131,13 +129,14 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
|
||||
var client = await _openIddictApplicationRepository.FindByClientIdAsync(name);
|
||||
|
||||
var application = new AbpApplicationDescriptor {
|
||||
var application = new AbpApplicationDescriptor
|
||||
{
|
||||
ClientId = name,
|
||||
ClientType = type,
|
||||
ClientSecret = secret,
|
||||
ConsentType = consentType,
|
||||
DisplayName = displayName,
|
||||
ClientUri = clientUri,
|
||||
ClientUri = clientUri
|
||||
};
|
||||
|
||||
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes));
|
||||
@ -160,7 +159,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
|
||||
}
|
||||
|
||||
var buildInGrantTypes = new[] {
|
||||
var buildInGrantTypes = new[]
|
||||
{
|
||||
OpenIddictConstants.GrantTypes.Implicit, OpenIddictConstants.GrantTypes.Password,
|
||||
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.ClientCredentials,
|
||||
OpenIddictConstants.GrantTypes.DeviceCode, OpenIddictConstants.GrantTypes.RefreshToken
|
||||
@ -233,7 +233,8 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
}
|
||||
}
|
||||
|
||||
var buildInScopes = new[] {
|
||||
var buildInScopes = new[]
|
||||
{
|
||||
OpenIddictConstants.Permissions.Scopes.Address, OpenIddictConstants.Permissions.Scopes.Email,
|
||||
OpenIddictConstants.Permissions.Scopes.Phone, OpenIddictConstants.Permissions.Scopes.Profile,
|
||||
OpenIddictConstants.Permissions.Scopes.Roles
|
||||
@ -289,8 +290,7 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
await _permissionDataSeeder.SeedAsync(
|
||||
ClientPermissionValueProvider.ProviderName,
|
||||
name,
|
||||
permissions,
|
||||
null
|
||||
permissions
|
||||
);
|
||||
}
|
||||
|
||||
@ -302,8 +302,10 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
|
||||
if (!HasSameRedirectUris(client, application))
|
||||
{
|
||||
client.RedirectUris = JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
|
||||
client.PostLogoutRedirectUris = JsonSerializer.Serialize(application.PostLogoutRedirectUris.Select(q => q.ToString().TrimEnd('/')));
|
||||
client.RedirectUris =
|
||||
JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
|
||||
client.PostLogoutRedirectUris =
|
||||
JsonSerializer.Serialize(application.PostLogoutRedirectUris.Select(q => q.ToString().TrimEnd('/')));
|
||||
|
||||
await _applicationManager.UpdateAsync(client.ToModel());
|
||||
}
|
||||
@ -317,11 +319,13 @@ public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDep
|
||||
|
||||
private bool HasSameRedirectUris(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
|
||||
{
|
||||
return existingClient.RedirectUris == JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
|
||||
return existingClient.RedirectUris ==
|
||||
JsonSerializer.Serialize(application.RedirectUris.Select(q => q.ToString().TrimEnd('/')));
|
||||
}
|
||||
|
||||
private bool HasSameScopes(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
|
||||
{
|
||||
return existingClient.Permissions == JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/')));
|
||||
return existingClient.Permissions ==
|
||||
JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString().TrimEnd('/')));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,4 +5,4 @@ public static class PaymentConsts
|
||||
public const string DbTablePrefix = "App";
|
||||
|
||||
public const string DbSchema = null;
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,6 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using KonSoft.Payment.MultiTenancy;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.DependencyInjection.Extensions;
|
||||
using KonSoft.Payment.MultiTenancy;
|
||||
using Volo.Abp.AuditLogging;
|
||||
using Volo.Abp.BackgroundJobs;
|
||||
using Volo.Abp.Emailing;
|
||||
@ -56,13 +56,10 @@ public class PaymentDomainModule : AbpModule
|
||||
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
|
||||
});
|
||||
|
||||
Configure<AbpMultiTenancyOptions>(options =>
|
||||
{
|
||||
options.IsEnabled = MultiTenancyConsts.IsEnabled;
|
||||
});
|
||||
Configure<AbpMultiTenancyOptions>(options => { options.IsEnabled = MultiTenancyConsts.IsEnabled; });
|
||||
|
||||
#if DEBUG
|
||||
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +1,4 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.Domain.Tests")]
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.TestBase")]
|
||||
|
||||
[assembly: InternalsVisibleToAttribute("KonSoft.Payment.Domain.Tests")]
|
||||
[assembly: InternalsVisibleToAttribute("KonSoft.Payment.TestBase")]
|
||||
@ -9,4 +9,4 @@ public class PaymentSettingDefinitionProvider : SettingDefinitionProvider
|
||||
//Define your own settings here. Example:
|
||||
//context.Add(new SettingDefinition(PaymentSettings.MySetting1));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,4 +6,4 @@ public static class PaymentSettings
|
||||
|
||||
//Add your own setting names here. Example:
|
||||
//public const string MySetting1 = Prefix + ".MySetting1";
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using KonSoft.Payment.Data;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using KonSoft.Payment.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
@ -31,4 +31,4 @@ public class EntityFrameworkCorePaymentDbSchemaMigrator
|
||||
.Database
|
||||
.MigrateAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -23,40 +23,9 @@ public class PaymentDbContext :
|
||||
IIdentityDbContext,
|
||||
ITenantManagementDbContext
|
||||
{
|
||||
/* Add DbSet properties for your Aggregate Roots / Entities here. */
|
||||
|
||||
#region Entities from the modules
|
||||
|
||||
/* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
|
||||
* and replaced them for this DbContext. This allows you to perform JOIN
|
||||
* queries for the entities of these modules over the repositories easily. You
|
||||
* typically don't need that for other modules. But, if you need, you can
|
||||
* implement the DbContext interface of the needed module and use ReplaceDbContext
|
||||
* attribute just like IIdentityDbContext and ITenantManagementDbContext.
|
||||
*
|
||||
* More info: Replacing a DbContext of a module ensures that the related module
|
||||
* uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
|
||||
*/
|
||||
|
||||
//Identity
|
||||
public DbSet<IdentityUser> Users { get; set; }
|
||||
public DbSet<IdentityRole> Roles { get; set; }
|
||||
public DbSet<IdentityClaimType> ClaimTypes { get; set; }
|
||||
public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
|
||||
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
|
||||
public DbSet<IdentityLinkUser> LinkUsers { get; set; }
|
||||
public DbSet<IdentityUserDelegation> UserDelegations { get; set; }
|
||||
public DbSet<IdentitySession> Sessions { get; set; }
|
||||
// Tenant Management
|
||||
public DbSet<Tenant> Tenants { get; set; }
|
||||
public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public PaymentDbContext(DbContextOptions<PaymentDbContext> options)
|
||||
: base(options)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder builder)
|
||||
@ -83,4 +52,35 @@ public class PaymentDbContext :
|
||||
// //...
|
||||
//});
|
||||
}
|
||||
}
|
||||
/* Add DbSet properties for your Aggregate Roots / Entities here. */
|
||||
|
||||
#region Entities from the modules
|
||||
|
||||
/* Notice: We only implemented IIdentityDbContext and ITenantManagementDbContext
|
||||
* and replaced them for this DbContext. This allows you to perform JOIN
|
||||
* queries for the entities of these modules over the repositories easily. You
|
||||
* typically don't need that for other modules. But, if you need, you can
|
||||
* implement the DbContext interface of the needed module and use ReplaceDbContext
|
||||
* attribute just like IIdentityDbContext and ITenantManagementDbContext.
|
||||
*
|
||||
* More info: Replacing a DbContext of a module ensures that the related module
|
||||
* uses this DbContext on runtime. Otherwise, it will use its own DbContext class.
|
||||
*/
|
||||
|
||||
//Identity
|
||||
public DbSet<IdentityUser> Users { get; set; }
|
||||
public DbSet<IdentityRole> Roles { get; set; }
|
||||
public DbSet<IdentityClaimType> ClaimTypes { get; set; }
|
||||
public DbSet<OrganizationUnit> OrganizationUnits { get; set; }
|
||||
public DbSet<IdentitySecurityLog> SecurityLogs { get; set; }
|
||||
public DbSet<IdentityLinkUser> LinkUsers { get; set; }
|
||||
public DbSet<IdentityUserDelegation> UserDelegations { get; set; }
|
||||
|
||||
public DbSet<IdentitySession> Sessions { get; set; }
|
||||
|
||||
// Tenant Management
|
||||
public DbSet<Tenant> Tenants { get; set; }
|
||||
public DbSet<TenantConnectionString> TenantConnectionStrings { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
@ -29,8 +29,8 @@ public class PaymentDbContextFactory : IDesignTimeDbContextFactory<PaymentDbCont
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../KonSoft.Payment.DbMigrator/"))
|
||||
.AddJsonFile("appsettings.json", optional: false);
|
||||
.AddJsonFile("appsettings.json", false);
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,13 +1,10 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public static class PaymentEfCoreEntityExtensionMappings
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
private static readonly OneTimeRunner OneTimeRunner = new();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
@ -16,29 +13,29 @@ public static class PaymentEfCoreEntityExtensionMappings
|
||||
|
||||
OneTimeRunner.Run(() =>
|
||||
{
|
||||
/* You can configure extra properties for the
|
||||
* entities defined in the modules used by your application.
|
||||
*
|
||||
* This class can be used to map these extra properties to table fields in the database.
|
||||
*
|
||||
* USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING.
|
||||
* USE PaymentModuleExtensionConfigurator CLASS (in the Domain.Shared project)
|
||||
* FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES
|
||||
*
|
||||
* Example: Map a property to a table field:
|
||||
/* You can configure extra properties for the
|
||||
* entities defined in the modules used by your application.
|
||||
*
|
||||
* This class can be used to map these extra properties to table fields in the database.
|
||||
*
|
||||
* USE THIS CLASS ONLY TO CONFIGURE EF CORE RELATED MAPPING.
|
||||
* USE PaymentModuleExtensionConfigurator CLASS (in the Domain.Shared project)
|
||||
* FOR A HIGH LEVEL API TO DEFINE EXTRA PROPERTIES TO ENTITIES OF THE USED MODULES
|
||||
*
|
||||
* Example: Map a property to a table field:
|
||||
|
||||
ObjectExtensionManager.Instance
|
||||
.MapEfCoreProperty<IdentityUser, string>(
|
||||
"MyProperty",
|
||||
(entityBuilder, propertyBuilder) =>
|
||||
{
|
||||
propertyBuilder.HasMaxLength(128);
|
||||
}
|
||||
);
|
||||
ObjectExtensionManager.Instance
|
||||
.MapEfCoreProperty<IdentityUser, string>(
|
||||
"MyProperty",
|
||||
(entityBuilder, propertyBuilder) =>
|
||||
{
|
||||
propertyBuilder.HasMaxLength(128);
|
||||
}
|
||||
);
|
||||
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
|
||||
*/
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.AuditLogging.EntityFrameworkCore;
|
||||
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
@ -26,7 +25,7 @@ namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
|
||||
typeof(AbpTenantManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpFeatureManagementEntityFrameworkCoreModule)
|
||||
)]
|
||||
)]
|
||||
public class PaymentEntityFrameworkCoreModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
@ -41,17 +40,16 @@ public class PaymentEntityFrameworkCoreModule : AbpModule
|
||||
{
|
||||
context.Services.AddAbpDbContext<PaymentDbContext>(options =>
|
||||
{
|
||||
/* Remove "includeAllEntities: true" to create
|
||||
* default repositories only for aggregate roots */
|
||||
options.AddDefaultRepositories(includeAllEntities: true);
|
||||
/* Remove "includeAllEntities: true" to create
|
||||
* default repositories only for aggregate roots */
|
||||
options.AddDefaultRepositories(true);
|
||||
});
|
||||
|
||||
Configure<AbpDbContextOptions>(options =>
|
||||
{
|
||||
/* The main point to change your DBMS.
|
||||
* See also PaymentMigrationsDbContextFactory for EF Core tooling. */
|
||||
/* The main point to change your DBMS.
|
||||
* See also PaymentMigrationsDbContextFactory for EF Core tooling. */
|
||||
options.UseNpgsql();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,2 +1,3 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.EntityFrameworkCore.Tests")]
|
||||
|
||||
[assembly: InternalsVisibleToAttribute("KonSoft.Payment.EntityFrameworkCore.Tests")]
|
||||
@ -4,8 +4,8 @@ using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
@ -26,8 +26,7 @@ public class PaymentHttpApiClientModule : AbpModule
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddHttpClientProxies(
|
||||
typeof(PaymentApplicationContractsModule).Assembly,
|
||||
RemoteServiceName
|
||||
typeof(PaymentApplicationContractsModule).Assembly
|
||||
);
|
||||
|
||||
Configure<AbpVirtualFileSystemOptions>(options =>
|
||||
@ -35,4 +34,4 @@ public class PaymentHttpApiClientModule : AbpModule
|
||||
options.FileSets.AddEmbedded<PaymentHttpApiClientModule>();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11,4 +11,4 @@ public abstract class PaymentController : AbpControllerBase
|
||||
{
|
||||
LocalizationResource = typeof(PaymentResource);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -7,4 +7,4 @@ public class TestModel
|
||||
public string? Name { get; set; }
|
||||
|
||||
public DateTime BirthDate { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using Localization.Resources.AbpUi;
|
||||
using KonSoft.Payment.Localization;
|
||||
using KonSoft.Payment.Localization;
|
||||
using Localization.Resources.AbpUi;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
@ -19,7 +19,7 @@ namespace KonSoft.Payment;
|
||||
typeof(AbpTenantManagementHttpApiModule),
|
||||
typeof(AbpFeatureManagementHttpApiModule),
|
||||
typeof(AbpSettingManagementHttpApiModule)
|
||||
)]
|
||||
)]
|
||||
public class PaymentHttpApiModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
@ -38,4 +38,4 @@ public class PaymentHttpApiModule : AbpModule
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -5,5 +5,4 @@ namespace KonSoft.Payment;
|
||||
public abstract class PaymentApplicationTestBase<TStartupModule> : PaymentTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -8,5 +8,4 @@ namespace KonSoft.Payment;
|
||||
)]
|
||||
public class PaymentApplicationTestModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
using Shouldly;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Shouldly;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Xunit;
|
||||
@ -31,4 +31,4 @@ public abstract class SampleAppServiceTests<TStartupModule> : PaymentApplication
|
||||
result.TotalCount.ShouldBeGreaterThan(0);
|
||||
result.Items.ShouldContain(u => u.UserName == "admin");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,5 +6,4 @@ namespace KonSoft.Payment;
|
||||
public abstract class PaymentDomainTestBase<TStartupModule> : PaymentTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -8,5 +8,4 @@ namespace KonSoft.Payment;
|
||||
)]
|
||||
public class PaymentDomainTestModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -14,8 +14,8 @@ namespace KonSoft.Payment.Samples;
|
||||
public abstract class SampleDomainTests<TStartupModule> : PaymentDomainTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
private readonly IIdentityUserRepository _identityUserRepository;
|
||||
private readonly IdentityUserManager _identityUserManager;
|
||||
private readonly IIdentityUserRepository _identityUserRepository;
|
||||
|
||||
protected SampleDomainTests()
|
||||
{
|
||||
@ -43,4 +43,4 @@ public abstract class SampleDomainTests<TStartupModule> : PaymentDomainTestBase<
|
||||
adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
|
||||
adminUser.Email.ShouldBe("newemail@abp.io");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -6,5 +6,4 @@ namespace KonSoft.Payment.EntityFrameworkCore.Applications;
|
||||
[Collection(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class EfCoreSampleAppServiceTests : SampleAppServiceTests<PaymentEntityFrameworkCoreTestModule>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -6,5 +6,4 @@ namespace KonSoft.Payment.EntityFrameworkCore.Domains;
|
||||
[Collection(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class EfCoreSampleDomainTests : SampleDomainTests<PaymentEntityFrameworkCoreTestModule>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -5,5 +5,4 @@ namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
[CollectionDefinition(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class PaymentEntityFrameworkCoreCollection : ICollectionFixture<PaymentEntityFrameworkCoreFixture>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,9 +1,7 @@
|
||||
using KonSoft.Payment.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public class PaymentEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture<PaymentEntityFrameworkCoreFixture>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -6,6 +6,5 @@ public class PaymentEntityFrameworkCoreFixture : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,5 @@
|
||||
using Volo.Abp;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public abstract class PaymentEntityFrameworkCoreTestBase : PaymentTestBase<PaymentEntityFrameworkCoreTestModule>
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -18,7 +18,7 @@ namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
typeof(PaymentApplicationTestModule),
|
||||
typeof(PaymentEntityFrameworkCoreModule),
|
||||
typeof(AbpEntityFrameworkCoreSqliteModule)
|
||||
)]
|
||||
)]
|
||||
public class PaymentEntityFrameworkCoreTestModule : AbpModule
|
||||
{
|
||||
private SqliteConnection? _sqliteConnection;
|
||||
@ -51,10 +51,7 @@ public class PaymentEntityFrameworkCoreTestModule : AbpModule
|
||||
|
||||
services.Configure<AbpDbContextOptions>(options =>
|
||||
{
|
||||
options.Configure(context =>
|
||||
{
|
||||
context.DbContextOptions.UseSqlite(_sqliteConnection);
|
||||
});
|
||||
options.Configure(context => { context.DbContextOptions.UseSqlite(_sqliteConnection); });
|
||||
});
|
||||
}
|
||||
|
||||
@ -79,4 +76,4 @@ public class PaymentEntityFrameworkCoreTestModule : AbpModule
|
||||
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Identity;
|
||||
using Xunit;
|
||||
@ -32,13 +32,13 @@ public class SampleRepositoryTests : PaymentEntityFrameworkCoreTestBase
|
||||
*/
|
||||
await WithUnitOfWorkAsync(async () =>
|
||||
{
|
||||
//Act
|
||||
var adminUser = await (await _appUserRepository.GetQueryableAsync())
|
||||
//Act
|
||||
var adminUser = await (await _appUserRepository.GetQueryableAsync())
|
||||
.Where(u => u.UserName == "admin")
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
//Assert
|
||||
adminUser.ShouldNotBeNull();
|
||||
//Assert
|
||||
adminUser.ShouldNotBeNull();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -22,4 +22,4 @@ public class ClientDemoService : ITransientDependency
|
||||
Console.WriteLine($"Name : {output.Name}");
|
||||
Console.WriteLine($"Surname : {output.Surname}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +1,8 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
@ -19,10 +19,10 @@ public class ConsoleTestAppHostedService : IHostedService
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using (var application = await AbpApplicationFactory.CreateAsync<PaymentConsoleApiClientModule>(options =>
|
||||
{
|
||||
options.Services.ReplaceConfiguration(_configuration);
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
options.Services.ReplaceConfiguration(_configuration);
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
await application.InitializeAsync();
|
||||
|
||||
@ -37,4 +37,4 @@ public class ConsoleTestAppHostedService : IHostedService
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -12,7 +12,7 @@ namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(PaymentHttpApiClientModule),
|
||||
typeof(AbpHttpClientIdentityModelModule)
|
||||
)]
|
||||
)]
|
||||
public class PaymentConsoleApiClientModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
@ -21,10 +21,10 @@ public class PaymentConsoleApiClientModule : AbpModule
|
||||
{
|
||||
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
|
||||
{
|
||||
clientBuilder.AddTransientHttpErrorPolicy(
|
||||
policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
|
||||
clientBuilder.AddTransientHttpErrorPolicy(policyBuilder =>
|
||||
policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,22 +1,23 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
class Program
|
||||
internal class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
private static async Task Main(string[] args)
|
||||
{
|
||||
await CreateHostBuilder(args).RunConsoleAsync();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
public static IHostBuilder CreateHostBuilder(string[] args)
|
||||
{
|
||||
return Host.CreateDefaultBuilder(args)
|
||||
.AddAppSettingsSecretsJson()
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHostedService<ConsoleTestAppHostedService>();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,8 +3,8 @@ using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.Testing;
|
||||
using Volo.Abp.Uow;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
@ -43,7 +43,8 @@ public abstract class PaymentTestBase<TStartupModule> : AbpIntegratedTest<TStart
|
||||
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
|
||||
}
|
||||
|
||||
protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, Func<Task<TResult>> func)
|
||||
protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options,
|
||||
Func<Task<TResult>> func)
|
||||
{
|
||||
using (var scope = ServiceProvider.CreateScope())
|
||||
{
|
||||
@ -57,4 +58,4 @@ public abstract class PaymentTestBase<TStartupModule> : AbpIntegratedTest<TStart
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -14,15 +14,12 @@ namespace KonSoft.Payment;
|
||||
typeof(AbpTestBaseModule),
|
||||
typeof(AbpAuthorizationModule),
|
||||
typeof(AbpBackgroundJobsAbstractionsModule)
|
||||
)]
|
||||
)]
|
||||
public class PaymentTestBaseModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpBackgroundJobOptions>(options =>
|
||||
{
|
||||
options.IsJobExecutionEnabled = false;
|
||||
});
|
||||
Configure<AbpBackgroundJobOptions>(options => { options.IsJobExecutionEnabled = false; });
|
||||
|
||||
context.Services.AddAlwaysAllowAuthorization();
|
||||
}
|
||||
@ -44,4 +41,4 @@ public class PaymentTestBaseModule : AbpModule
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3,4 +3,4 @@
|
||||
public static class PaymentTestConsts
|
||||
{
|
||||
public const string CollectionDefinitionName = "Payment collection";
|
||||
}
|
||||
}
|
||||
@ -12,4 +12,4 @@ public class PaymentTestDataSeedContributor : IDataSeedContributor, ITransientDe
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -17,9 +17,9 @@ public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor
|
||||
{
|
||||
return new ClaimsPrincipal(new ClaimsIdentity(new List<Claim>
|
||||
{
|
||||
new Claim(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"),
|
||||
new Claim(AbpClaimTypes.UserName, "admin"),
|
||||
new Claim(AbpClaimTypes.Email, "admin@abp.io")
|
||||
new(AbpClaimTypes.UserId, "2e701e62-0953-4dd3-910b-dc6cc93ccb0d"),
|
||||
new(AbpClaimTypes.UserName, "admin"),
|
||||
new(AbpClaimTypes.Email, "admin@abp.io")
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user