first commit
This commit is contained in:
@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Payment.Domain.Shared\KonSoft.Payment.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.ObjectExtending" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Account.Application.Contracts" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Identity.Application.Contracts" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Application.Contracts" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.Application.Contracts" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Application.Contracts" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.Application.Contracts" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,28 @@
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentDomainSharedModule),
|
||||
typeof(AbpAccountApplicationContractsModule),
|
||||
typeof(AbpFeatureManagementApplicationContractsModule),
|
||||
typeof(AbpIdentityApplicationContractsModule),
|
||||
typeof(AbpPermissionManagementApplicationContractsModule),
|
||||
typeof(AbpSettingManagementApplicationContractsModule),
|
||||
typeof(AbpTenantManagementApplicationContractsModule),
|
||||
typeof(AbpObjectExtendingModule)
|
||||
)]
|
||||
public class PaymentApplicationContractsModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PaymentDtoExtensions.Configure();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentDtoExtensions
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
|
||||
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
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
using KonSoft.Payment.Localization;
|
||||
using Volo.Abp.Authorization.Permissions;
|
||||
using Volo.Abp.Localization;
|
||||
|
||||
namespace KonSoft.Payment.Permissions;
|
||||
|
||||
public class PaymentPermissionDefinitionProvider : PermissionDefinitionProvider
|
||||
{
|
||||
public override void Define(IPermissionDefinitionContext context)
|
||||
{
|
||||
var myGroup = context.AddGroup(PaymentPermissions.GroupName);
|
||||
//Define your own permissions here. Example:
|
||||
//myGroup.AddPermission(PaymentPermissions.MyPermission1, L("Permission:MyPermission1"));
|
||||
}
|
||||
|
||||
private static LocalizableString L(string name)
|
||||
{
|
||||
return LocalizableString.Create<PaymentResource>(name);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
namespace KonSoft.Payment.Permissions;
|
||||
|
||||
public static class PaymentPermissions
|
||||
{
|
||||
public const string GroupName = "Payment";
|
||||
|
||||
//Add your own permission names. Example:
|
||||
//public const string MyPermission1 = GroupName + ".MyPermission1";
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Payment.Domain\KonSoft.Payment.Domain.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Payment.Application.Contracts\KonSoft.Payment.Application.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Account.Application" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Identity.Application" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Application" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.Application" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Application" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.Application" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using KonSoft.Payment.Localization;
|
||||
using Volo.Abp.Application.Services;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
/* Inherit your application services from this class.
|
||||
*/
|
||||
public abstract class PaymentAppService : ApplicationService
|
||||
{
|
||||
protected PaymentAppService()
|
||||
{
|
||||
LocalizationResource = typeof(PaymentResource);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,13 @@
|
||||
using AutoMapper;
|
||||
|
||||
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. */
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.AutoMapper;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentDomainModule),
|
||||
typeof(AbpAccountApplicationModule),
|
||||
typeof(PaymentApplicationContractsModule),
|
||||
typeof(AbpIdentityApplicationModule),
|
||||
typeof(AbpPermissionManagementApplicationModule),
|
||||
typeof(AbpTenantManagementApplicationModule),
|
||||
typeof(AbpFeatureManagementApplicationModule),
|
||||
typeof(AbpSettingManagementApplicationModule)
|
||||
)]
|
||||
public class PaymentApplicationModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpAutoMapperOptions>(options =>
|
||||
{
|
||||
options.AddMaps<PaymentApplicationModule>();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.Application.Tests")]
|
||||
@ -0,0 +1,32 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Identity.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AuditLogging.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.Domain.Shared" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.OpenIddict.Domain.Shared" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Localization\Payment\*.json" />
|
||||
<Content Remove="Localization\Payment\*.json" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "ar",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "الصفحة الرئيسية",
|
||||
"Welcome": "مرحباً",
|
||||
"LongWelcomeMessage": "مرحبا بكم في التطبيق. هذا مشروع بدء تشغيل يعتمد على إطار عمل ABP. لمزيد من المعلومات ، يرجى زيارة abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "cs",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"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,9 @@
|
||||
{
|
||||
"culture": "de",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Home",
|
||||
"Welcome": "Willkommen",
|
||||
"LongWelcomeMessage": "Willkommen bei der Anwendung. Dies ist ein Startup-Projekt, das auf dem ABP-Framework basiert. Weitere Informationen finden Sie unter abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "en-GB",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Home",
|
||||
"Welcome": "Welcome",
|
||||
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "en",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Home",
|
||||
"Welcome": "Welcome",
|
||||
"LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "es",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Inicio",
|
||||
"Welcome": "Bienvenido",
|
||||
"LongWelcomeMessage": "Bienvenido a la aplicación, este es un proyecto base basado en el framework ABP. Para más información, visita abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "fi",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Koti",
|
||||
"Welcome": "Tervetuloa",
|
||||
"LongWelcomeMessage": "Tervetuloa sovellukseen. Tämä on ABP-kehykseen perustuva käynnistysprojekti. Lisätietoja on osoitteessa abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "fr",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Accueil",
|
||||
"Welcome": "Bienvenue",
|
||||
"LongWelcomeMessage": "Bienvenue dans l'application. Il s'agit d'un projet de démarrage basé sur le framework ABP. Pour plus d'informations, visitez abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "hi",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "घर",
|
||||
"Welcome": "स्वागत हे",
|
||||
"LongWelcomeMessage": "आवेदन करने के लिए आपका स्वागत है। यह एबीपी ढांचे पर आधारित एक स्टार्टअप परियोजना है। अधिक जानकारी के लिए, abp.io पर जाएं।"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "hr",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Početna",
|
||||
"Welcome": "Dobrodošli",
|
||||
"LongWelcomeMessage": "Dobrodošli u aplikaciju. Ovo je startup projekt temeljen na ABP framework-u. Za više informacija posjetite abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "hu",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Kezdőlap",
|
||||
"Welcome": "Üdvözlöm",
|
||||
"LongWelcomeMessage": "Üdvözöljük az alkalmazásban. Ez egy ABP keretrendszeren alapuló startup projekt. További információkért látogasson el az abp.io oldalra."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "is",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Heim",
|
||||
"Welcome": "Velkomin",
|
||||
"LongWelcomeMessage": "Verið velkomin í forritið. Þetta er startup verkefni sem byggir á ABP. Nánari upplýsingar er að finna á abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "it",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Home",
|
||||
"Welcome": "Benvenuto",
|
||||
"LongWelcomeMessage": "Benvenuto nell'applicazione. Questo è un progetto di avvio basato sul framework ABP. Per ulteriori informazioni, visita abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "nl",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Home",
|
||||
"Welcome": "Welkom",
|
||||
"LongWelcomeMessage": "Welkom bij de applicatie. Dit is een startup-project gebaseerd op het ABP-framework. Bezoek abp.io voor meer informatie."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "pl-PL",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Home",
|
||||
"Welcome": "Witaj",
|
||||
"LongWelcomeMessage": "Witaj w aplikacji. To jest inicjalny projekt bazujący na ABP framework. Po więcej informacji odwiedź stronę abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "pt-BR",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Principal",
|
||||
"Welcome": "Seja bem-vindo!",
|
||||
"LongWelcomeMessage": "Bem-vindo a esta aplicação. Este é um projeto inicial baseado no ABP framework. Para mais informações, visite abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "ro-RO",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Acasă",
|
||||
"Welcome": "Bun venit",
|
||||
"LongWelcomeMessage": "Bun venit la aplicaţie. Acesta este un proiect de pornire bazat pe framework-ul ABP. Pentru mai multe informaţii, vizitaţi, visit abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "ru",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Главная",
|
||||
"Welcome": "Добро пожаловать",
|
||||
"LongWelcomeMessage": "Добро пожаловать в приложение. Этот запущенный проект основан на фреймворке ABP. Для получения дополнительной информации посетите сайт abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "sk",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Domov",
|
||||
"Welcome": "Vitajte",
|
||||
"LongWelcomeMessage": "Vitajte v aplikácii. Toto je štartovací projekt založený na ABP frameworku. Viac informácií nájdete na stránke abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "sl",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Domov",
|
||||
"Welcome": "Dobrodošli",
|
||||
"LongWelcomeMessage": "Dobrodošli v aplikaciji. To je začetni projekt na osnovi okolja ABP. Za več informacij obiščite abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "sv",
|
||||
"texts": {
|
||||
"AppName": "MittProjektNamn",
|
||||
"Menu:Home": "Hem",
|
||||
"Welcome": "Välkommen",
|
||||
"LongWelcomeMessage": "Välkommen till applikationen. Detta är ett startup-projekt baserat på ABP-ramverket. För mer information, besök abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "tr",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"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,9 @@
|
||||
{
|
||||
"culture": "vi",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "Trang chủ",
|
||||
"Welcome": "Chào mừng bạn",
|
||||
"LongWelcomeMessage": "Chào mừng bạn đến ứng dụng. Đây là một dự án khởi nghiệp dựa trên khung ABP. Để biết thêm thông tin, hãy truy cập abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "zh-Hans",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "首页",
|
||||
"Welcome": "欢迎",
|
||||
"LongWelcomeMessage": "欢迎使用本应用程序。这是一个基于 ABP 框架的启动项目。更多信息,请访问 abp.io。"
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
{
|
||||
"culture": "zh-Hant",
|
||||
"texts": {
|
||||
"AppName": "Payment",
|
||||
"Menu:Home": "首頁",
|
||||
"Welcome": "歡迎",
|
||||
"LongWelcomeMessage": "歡迎來到此應用程式. 這是一個基於ABP框架的起始專案. 有關更多訊息, 請瀏覽 abp.io."
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
using Volo.Abp.Localization;
|
||||
|
||||
namespace KonSoft.Payment.Localization;
|
||||
|
||||
[LocalizationResourceName("Payment")]
|
||||
public class PaymentResource
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
namespace KonSoft.Payment.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;
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentDomainErrorCodes
|
||||
{
|
||||
/* You can add your business exception error codes here, as constants */
|
||||
}
|
||||
@ -0,0 +1,58 @@
|
||||
using KonSoft.Payment.Localization;
|
||||
using Volo.Abp.AuditLogging;
|
||||
using Volo.Abp.BackgroundJobs;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Localization.ExceptionHandling;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.OpenIddict;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using Volo.Abp.Validation.Localization;
|
||||
using Volo.Abp.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAuditLoggingDomainSharedModule),
|
||||
typeof(AbpBackgroundJobsDomainSharedModule),
|
||||
typeof(AbpFeatureManagementDomainSharedModule),
|
||||
typeof(AbpIdentityDomainSharedModule),
|
||||
typeof(AbpOpenIddictDomainSharedModule),
|
||||
typeof(AbpPermissionManagementDomainSharedModule),
|
||||
typeof(AbpSettingManagementDomainSharedModule),
|
||||
typeof(AbpTenantManagementDomainSharedModule)
|
||||
)]
|
||||
public class PaymentDomainSharedModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PaymentGlobalFeatureConfigurator.Configure();
|
||||
PaymentModuleExtensionConfigurator.Configure();
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpVirtualFileSystemOptions>(options =>
|
||||
{
|
||||
options.FileSets.AddEmbedded<PaymentDomainSharedModule>();
|
||||
});
|
||||
|
||||
Configure<AbpLocalizationOptions>(options =>
|
||||
{
|
||||
options.Resources
|
||||
.Add<PaymentResource>("en")
|
||||
.AddBaseTypes(typeof(AbpValidationResource))
|
||||
.AddVirtualJson("/Localization/Payment");
|
||||
|
||||
options.DefaultResourceType = typeof(PaymentResource);
|
||||
});
|
||||
|
||||
Configure<AbpExceptionLocalizationOptions>(options =>
|
||||
{
|
||||
options.MapCodeNamespace("Payment", typeof(PaymentResource));
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentGlobalFeatureConfigurator
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
|
||||
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
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,73 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentModuleExtensionConfigurator
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
OneTimeRunner.Run(() =>
|
||||
{
|
||||
ConfigureExistingProperties();
|
||||
ConfigureExtraProperties();
|
||||
});
|
||||
}
|
||||
|
||||
private static void ConfigureExistingProperties()
|
||||
{
|
||||
/* You can change max lengths for properties of the
|
||||
* entities defined in the modules used by your application.
|
||||
*
|
||||
* Example: Change user and role name max lengths
|
||||
|
||||
AbpUserConsts.MaxNameLength = 99;
|
||||
IdentityRoleConsts.MaxNameLength = 99;
|
||||
|
||||
* Notice: It is not suggested to change property lengths
|
||||
* unless you really need it. Go with the standard values wherever possible.
|
||||
*
|
||||
* If you are using EF Core, you will need to run the add-migration command after your changes.
|
||||
*/
|
||||
}
|
||||
|
||||
private static void ConfigureExtraProperties()
|
||||
{
|
||||
/* You can configure extra properties for the
|
||||
* entities defined in the modules used by your application.
|
||||
*
|
||||
* This class can be used to define these extra properties
|
||||
* with a high level, easy to use API.
|
||||
*
|
||||
* Example: Add a new property to the user entity of the identity module
|
||||
|
||||
ObjectExtensionManager.Instance.Modules()
|
||||
.ConfigureIdentity(identity =>
|
||||
{
|
||||
identity.ConfigureUser(user =>
|
||||
{
|
||||
user.AddOrUpdateProperty<string>( //property type: string
|
||||
"SocialSecurityNumber", //property name
|
||||
property =>
|
||||
{
|
||||
//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
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
* See the documentation for more:
|
||||
* https://docs.abp.io/en/abp/latest/Module-Entity-Extensions
|
||||
*/
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KonSoft.Payment.Data;
|
||||
|
||||
public interface IPaymentDbSchemaMigrator
|
||||
{
|
||||
Task MigrateAsync();
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Payment.Data;
|
||||
|
||||
/* This is used if database provider does't define
|
||||
* IPaymentDbSchemaMigrator implementation.
|
||||
*/
|
||||
public class NullPaymentDbSchemaMigrator : IPaymentDbSchemaMigrator, ITransientDependency
|
||||
{
|
||||
public Task MigrateAsync()
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,218 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Logging.Abstractions;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.TenantManagement;
|
||||
|
||||
namespace KonSoft.Payment.Data;
|
||||
|
||||
public class PaymentDbMigrationService : ITransientDependency
|
||||
{
|
||||
public ILogger<PaymentDbMigrationService> Logger { get; set; }
|
||||
|
||||
private readonly IDataSeeder _dataSeeder;
|
||||
private readonly IEnumerable<IPaymentDbSchemaMigrator> _dbSchemaMigrators;
|
||||
private readonly ITenantRepository _tenantRepository;
|
||||
private readonly ICurrentTenant _currentTenant;
|
||||
|
||||
public PaymentDbMigrationService(
|
||||
IDataSeeder dataSeeder,
|
||||
IEnumerable<IPaymentDbSchemaMigrator> dbSchemaMigrators,
|
||||
ITenantRepository tenantRepository,
|
||||
ICurrentTenant currentTenant)
|
||||
{
|
||||
_dataSeeder = dataSeeder;
|
||||
_dbSchemaMigrators = dbSchemaMigrators;
|
||||
_tenantRepository = tenantRepository;
|
||||
_currentTenant = currentTenant;
|
||||
|
||||
Logger = NullLogger<PaymentDbMigrationService>.Instance;
|
||||
}
|
||||
|
||||
public async Task MigrateAsync()
|
||||
{
|
||||
var initialMigrationAdded = AddInitialMigrationIfNotExist();
|
||||
|
||||
if (initialMigrationAdded)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Logger.LogInformation("Started database migrations...");
|
||||
|
||||
await MigrateDatabaseSchemaAsync();
|
||||
await SeedDataAsync();
|
||||
|
||||
Logger.LogInformation($"Successfully completed host database migrations.");
|
||||
|
||||
var tenants = await _tenantRepository.GetListAsync(includeDetails: true);
|
||||
|
||||
var migratedDatabaseSchemas = new HashSet<string>();
|
||||
foreach (var tenant in tenants)
|
||||
{
|
||||
using (_currentTenant.Change(tenant.Id))
|
||||
{
|
||||
if (tenant.ConnectionStrings.Any())
|
||||
{
|
||||
var tenantConnectionStrings = tenant.ConnectionStrings
|
||||
.Select(x => x.Value)
|
||||
.ToList();
|
||||
|
||||
if (!migratedDatabaseSchemas.IsSupersetOf(tenantConnectionStrings))
|
||||
{
|
||||
await MigrateDatabaseSchemaAsync(tenant);
|
||||
|
||||
migratedDatabaseSchemas.AddIfNotContains(tenantConnectionStrings);
|
||||
}
|
||||
}
|
||||
|
||||
await SeedDataAsync(tenant);
|
||||
}
|
||||
|
||||
Logger.LogInformation($"Successfully completed {tenant.Name} tenant database migrations.");
|
||||
}
|
||||
|
||||
Logger.LogInformation("Successfully completed all database migrations.");
|
||||
Logger.LogInformation("You can safely end this process...");
|
||||
}
|
||||
|
||||
private async Task MigrateDatabaseSchemaAsync(Tenant? tenant = null)
|
||||
{
|
||||
Logger.LogInformation(
|
||||
$"Migrating schema for {(tenant == null ? "host" : tenant.Name + " tenant")} database...");
|
||||
|
||||
foreach (var migrator in _dbSchemaMigrators)
|
||||
{
|
||||
await migrator.MigrateAsync();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task SeedDataAsync(Tenant? tenant = null)
|
||||
{
|
||||
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)
|
||||
);
|
||||
}
|
||||
|
||||
private bool AddInitialMigrationIfNotExist()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!DbMigrationsProjectExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!MigrationsFolderExists())
|
||||
{
|
||||
AddInitialMigration();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.LogWarning("Couldn't determinate if any migrations exist : " + e.Message);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private bool DbMigrationsProjectExists()
|
||||
{
|
||||
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
|
||||
|
||||
return dbMigrationsProjectFolder != null;
|
||||
}
|
||||
|
||||
private bool MigrationsFolderExists()
|
||||
{
|
||||
var dbMigrationsProjectFolder = GetEntityFrameworkCoreProjectFolderPath();
|
||||
return dbMigrationsProjectFolder != null && Directory.Exists(Path.Combine(dbMigrationsProjectFolder, "Migrations"));
|
||||
}
|
||||
|
||||
private void AddInitialMigration()
|
||||
{
|
||||
Logger.LogInformation("Creating initial migration...");
|
||||
|
||||
string argumentPrefix;
|
||||
string fileName;
|
||||
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX) || RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
|
||||
{
|
||||
argumentPrefix = "-c";
|
||||
fileName = "/bin/bash";
|
||||
}
|
||||
else
|
||||
{
|
||||
argumentPrefix = "/C";
|
||||
fileName = "cmd.exe";
|
||||
}
|
||||
|
||||
var procStartInfo = new ProcessStartInfo(fileName,
|
||||
$"{argumentPrefix} \"abp create-migration-and-run-migrator \"{GetEntityFrameworkCoreProjectFolderPath()}\"\""
|
||||
);
|
||||
|
||||
try
|
||||
{
|
||||
Process.Start(procStartInfo);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
throw new Exception("Couldn't run ABP CLI...");
|
||||
}
|
||||
}
|
||||
|
||||
private string? GetEntityFrameworkCoreProjectFolderPath()
|
||||
{
|
||||
var slnDirectoryPath = GetSolutionDirectoryPath();
|
||||
|
||||
if (slnDirectoryPath == null)
|
||||
{
|
||||
throw new Exception("Solution folder not found!");
|
||||
}
|
||||
|
||||
var srcDirectoryPath = Path.Combine(slnDirectoryPath, "src");
|
||||
|
||||
return Directory.GetDirectories(srcDirectoryPath)
|
||||
.FirstOrDefault(d => d.EndsWith(".EntityFrameworkCore"));
|
||||
}
|
||||
|
||||
private string? GetSolutionDirectoryPath()
|
||||
{
|
||||
var currentDirectory = new DirectoryInfo(Directory.GetCurrentDirectory());
|
||||
|
||||
while (currentDirectory != null && Directory.GetParent(currentDirectory.FullName) != null)
|
||||
{
|
||||
currentDirectory = Directory.GetParent(currentDirectory.FullName);
|
||||
|
||||
if (currentDirectory != null && Directory.GetFiles(currentDirectory.FullName).FirstOrDefault(f => f.EndsWith(".sln")) != null)
|
||||
{
|
||||
return currentDirectory.FullName;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,28 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Payment.Domain.Shared\KonSoft.Payment.Domain.Shared.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Emailing" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Identity.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.Identity" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AuditLogging.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.OpenIddict.Domain" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.Domain.OpenIddict" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,327 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using JetBrains.Annotations;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Localization;
|
||||
using OpenIddict.Abstractions;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Authorization.Permissions;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.OpenIddict.Applications;
|
||||
using Volo.Abp.OpenIddict.Scopes;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.Uow;
|
||||
|
||||
namespace KonSoft.Payment.OpenIddict;
|
||||
|
||||
/* Creates initial data that is needed to property run the application
|
||||
* and make client-to-server communication possible.
|
||||
*/
|
||||
public class OpenIddictDataSeedContributor : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
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 IStringLocalizer<OpenIddictResponse> L;
|
||||
|
||||
public OpenIddictDataSeedContributor(
|
||||
IConfiguration configuration,
|
||||
IOpenIddictApplicationRepository openIddictApplicationRepository,
|
||||
IAbpApplicationManager applicationManager,
|
||||
IOpenIddictScopeRepository openIddictScopeRepository,
|
||||
IOpenIddictScopeManager scopeManager,
|
||||
IPermissionDataSeeder permissionDataSeeder,
|
||||
IStringLocalizer<OpenIddictResponse> l )
|
||||
{
|
||||
_configuration = configuration;
|
||||
_openIddictApplicationRepository = openIddictApplicationRepository;
|
||||
_applicationManager = applicationManager;
|
||||
_openIddictScopeRepository = openIddictScopeRepository;
|
||||
_scopeManager = scopeManager;
|
||||
_permissionDataSeeder = permissionDataSeeder;
|
||||
L = l;
|
||||
}
|
||||
|
||||
[UnitOfWork]
|
||||
public virtual async Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
await CreateScopesAsync();
|
||||
await CreateApplicationsAsync();
|
||||
}
|
||||
|
||||
private async Task CreateScopesAsync()
|
||||
{
|
||||
if (await _openIddictScopeRepository.FindByNameAsync("Payment") == null)
|
||||
{
|
||||
await _scopeManager.CreateAsync(new OpenIddictScopeDescriptor {
|
||||
Name = "Payment", DisplayName = "Payment API", Resources = { "Payment" }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreateApplicationsAsync()
|
||||
{
|
||||
var commonScopes = new List<string> {
|
||||
OpenIddictConstants.Permissions.Scopes.Address,
|
||||
OpenIddictConstants.Permissions.Scopes.Email,
|
||||
OpenIddictConstants.Permissions.Scopes.Phone,
|
||||
OpenIddictConstants.Permissions.Scopes.Profile,
|
||||
OpenIddictConstants.Permissions.Scopes.Roles,
|
||||
"Payment"
|
||||
};
|
||||
|
||||
var configurationSection = _configuration.GetSection("OpenIddict:Applications");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Swagger Client
|
||||
var swaggerClientId = configurationSection["Payment_Swagger:ClientId"];
|
||||
if (!swaggerClientId.IsNullOrWhiteSpace())
|
||||
{
|
||||
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: new List<string> { OpenIddictConstants.GrantTypes.AuthorizationCode, },
|
||||
scopes: commonScopes,
|
||||
redirectUri: $"{swaggerRootUrl}/swagger/oauth2-redirect.html",
|
||||
clientUri: swaggerRootUrl
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CreateApplicationAsync(
|
||||
[NotNull] string name,
|
||||
[NotNull] string type,
|
||||
[NotNull] string consentType,
|
||||
string displayName,
|
||||
string? secret,
|
||||
List<string> grantTypes,
|
||||
List<string> scopes,
|
||||
string? clientUri = null,
|
||||
string? redirectUri = null,
|
||||
string? postLogoutRedirectUri = null,
|
||||
List<string>? permissions = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Public,
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new BusinessException(L["NoClientSecretCanBeSetForPublicApplications"]);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(secret) && string.Equals(type, OpenIddictConstants.ClientTypes.Confidential,
|
||||
StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
throw new BusinessException(L["TheClientSecretIsRequiredForConfidentialApplications"]);
|
||||
}
|
||||
|
||||
var client = await _openIddictApplicationRepository.FindByClientIdAsync(name);
|
||||
|
||||
var application = new AbpApplicationDescriptor {
|
||||
ClientId = name,
|
||||
ClientType = type,
|
||||
ClientSecret = secret,
|
||||
ConsentType = consentType,
|
||||
DisplayName = displayName,
|
||||
ClientUri = clientUri,
|
||||
};
|
||||
|
||||
Check.NotNullOrEmpty(grantTypes, nameof(grantTypes));
|
||||
Check.NotNullOrEmpty(scopes, nameof(scopes));
|
||||
|
||||
if (new[] { OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.Implicit }.All(
|
||||
grantTypes.Contains))
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdToken);
|
||||
|
||||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeIdTokenToken);
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.CodeToken);
|
||||
}
|
||||
}
|
||||
|
||||
if (!redirectUri.IsNullOrWhiteSpace() || !postLogoutRedirectUri.IsNullOrWhiteSpace())
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Logout);
|
||||
}
|
||||
|
||||
var buildInGrantTypes = new[] {
|
||||
OpenIddictConstants.GrantTypes.Implicit, OpenIddictConstants.GrantTypes.Password,
|
||||
OpenIddictConstants.GrantTypes.AuthorizationCode, OpenIddictConstants.GrantTypes.ClientCredentials,
|
||||
OpenIddictConstants.GrantTypes.DeviceCode, OpenIddictConstants.GrantTypes.RefreshToken
|
||||
};
|
||||
|
||||
foreach (var grantType in grantTypes)
|
||||
{
|
||||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.AuthorizationCode);
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Code);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode ||
|
||||
grantType == OpenIddictConstants.GrantTypes.Implicit)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Authorization);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.AuthorizationCode ||
|
||||
grantType == OpenIddictConstants.GrantTypes.ClientCredentials ||
|
||||
grantType == OpenIddictConstants.GrantTypes.Password ||
|
||||
grantType == OpenIddictConstants.GrantTypes.RefreshToken ||
|
||||
grantType == OpenIddictConstants.GrantTypes.DeviceCode)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Token);
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Revocation);
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Introspection);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.ClientCredentials)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.ClientCredentials);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Implicit);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.Password)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.Password);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.RefreshToken)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.RefreshToken);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.DeviceCode)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.GrantTypes.DeviceCode);
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Endpoints.Device);
|
||||
}
|
||||
|
||||
if (grantType == OpenIddictConstants.GrantTypes.Implicit)
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdToken);
|
||||
if (string.Equals(type, OpenIddictConstants.ClientTypes.Public, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.IdTokenToken);
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.ResponseTypes.Token);
|
||||
}
|
||||
}
|
||||
|
||||
if (!buildInGrantTypes.Contains(grantType))
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.GrantType + grantType);
|
||||
}
|
||||
}
|
||||
|
||||
var buildInScopes = new[] {
|
||||
OpenIddictConstants.Permissions.Scopes.Address, OpenIddictConstants.Permissions.Scopes.Email,
|
||||
OpenIddictConstants.Permissions.Scopes.Phone, OpenIddictConstants.Permissions.Scopes.Profile,
|
||||
OpenIddictConstants.Permissions.Scopes.Roles
|
||||
};
|
||||
|
||||
foreach (var scope in scopes)
|
||||
{
|
||||
if (buildInScopes.Contains(scope))
|
||||
{
|
||||
application.Permissions.Add(scope);
|
||||
}
|
||||
else
|
||||
{
|
||||
application.Permissions.Add(OpenIddictConstants.Permissions.Prefixes.Scope + scope);
|
||||
}
|
||||
}
|
||||
|
||||
if (redirectUri != null)
|
||||
{
|
||||
if (!redirectUri.IsNullOrEmpty())
|
||||
{
|
||||
if (!Uri.TryCreate(redirectUri, UriKind.Absolute, out var uri) || !uri.IsWellFormedOriginalString())
|
||||
{
|
||||
throw new BusinessException(L["InvalidRedirectUri", redirectUri]);
|
||||
}
|
||||
|
||||
if (application.RedirectUris.All(x => x != uri))
|
||||
{
|
||||
application.RedirectUris.Add(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (postLogoutRedirectUri != null)
|
||||
{
|
||||
if (!postLogoutRedirectUri.IsNullOrEmpty())
|
||||
{
|
||||
if (!Uri.TryCreate(postLogoutRedirectUri, UriKind.Absolute, out var uri) ||
|
||||
!uri.IsWellFormedOriginalString())
|
||||
{
|
||||
throw new BusinessException(L["InvalidPostLogoutRedirectUri", postLogoutRedirectUri]);
|
||||
}
|
||||
|
||||
if (application.PostLogoutRedirectUris.All(x => x != uri))
|
||||
{
|
||||
application.PostLogoutRedirectUris.Add(uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (permissions != null)
|
||||
{
|
||||
await _permissionDataSeeder.SeedAsync(
|
||||
ClientPermissionValueProvider.ProviderName,
|
||||
name,
|
||||
permissions,
|
||||
null
|
||||
);
|
||||
}
|
||||
|
||||
if (client == null)
|
||||
{
|
||||
await _applicationManager.CreateAsync(application);
|
||||
return;
|
||||
}
|
||||
|
||||
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('/')));
|
||||
|
||||
await _applicationManager.UpdateAsync(client.ToModel());
|
||||
}
|
||||
|
||||
if (!HasSameScopes(client, application))
|
||||
{
|
||||
client.Permissions = JsonSerializer.Serialize(application.Permissions.Select(q => q.ToString()));
|
||||
await _applicationManager.UpdateAsync(client.ToModel());
|
||||
}
|
||||
}
|
||||
|
||||
private bool HasSameRedirectUris(OpenIddictApplication existingClient, AbpApplicationDescriptor application)
|
||||
{
|
||||
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('/')));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentConsts
|
||||
{
|
||||
public const string DbTablePrefix = "App";
|
||||
|
||||
public const string DbSchema = null;
|
||||
}
|
||||
@ -0,0 +1,68 @@
|
||||
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;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.MultiTenancy;
|
||||
using Volo.Abp.OpenIddict;
|
||||
using Volo.Abp.PermissionManagement.Identity;
|
||||
using Volo.Abp.PermissionManagement.OpenIddict;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentDomainSharedModule),
|
||||
typeof(AbpAuditLoggingDomainModule),
|
||||
typeof(AbpBackgroundJobsDomainModule),
|
||||
typeof(AbpFeatureManagementDomainModule),
|
||||
typeof(AbpIdentityDomainModule),
|
||||
typeof(AbpOpenIddictDomainModule),
|
||||
typeof(AbpPermissionManagementDomainOpenIddictModule),
|
||||
typeof(AbpPermissionManagementDomainIdentityModule),
|
||||
typeof(AbpSettingManagementDomainModule),
|
||||
typeof(AbpTenantManagementDomainModule),
|
||||
typeof(AbpEmailingModule)
|
||||
)]
|
||||
public class PaymentDomainModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpLocalizationOptions>(options =>
|
||||
{
|
||||
options.Languages.Add(new LanguageInfo("ar", "ar", "العربية"));
|
||||
options.Languages.Add(new LanguageInfo("cs", "cs", "Čeština"));
|
||||
options.Languages.Add(new LanguageInfo("en", "en", "English"));
|
||||
options.Languages.Add(new LanguageInfo("en-GB", "en-GB", "English (UK)"));
|
||||
options.Languages.Add(new LanguageInfo("hu", "hu", "Magyar"));
|
||||
options.Languages.Add(new LanguageInfo("hr", "hr", "Croatian"));
|
||||
options.Languages.Add(new LanguageInfo("fi", "fi", "Finnish"));
|
||||
options.Languages.Add(new LanguageInfo("fr", "fr", "Français"));
|
||||
options.Languages.Add(new LanguageInfo("hi", "hi", "Hindi"));
|
||||
options.Languages.Add(new LanguageInfo("it", "it", "Italiano"));
|
||||
options.Languages.Add(new LanguageInfo("pt-BR", "pt-BR", "Português"));
|
||||
options.Languages.Add(new LanguageInfo("ru", "ru", "Русский"));
|
||||
options.Languages.Add(new LanguageInfo("sk", "sk", "Slovak"));
|
||||
options.Languages.Add(new LanguageInfo("tr", "tr", "Türkçe"));
|
||||
options.Languages.Add(new LanguageInfo("zh-Hans", "zh-Hans", "简体中文"));
|
||||
options.Languages.Add(new LanguageInfo("zh-Hant", "zh-Hant", "繁體中文"));
|
||||
options.Languages.Add(new LanguageInfo("de-DE", "de-DE", "Deutsch"));
|
||||
options.Languages.Add(new LanguageInfo("es", "es", "Español"));
|
||||
});
|
||||
|
||||
Configure<AbpMultiTenancyOptions>(options =>
|
||||
{
|
||||
options.IsEnabled = MultiTenancyConsts.IsEnabled;
|
||||
});
|
||||
|
||||
#if DEBUG
|
||||
context.Services.Replace(ServiceDescriptor.Singleton<IEmailSender, NullEmailSender>());
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,3 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.Domain.Tests")]
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.TestBase")]
|
||||
@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Settings;
|
||||
|
||||
namespace KonSoft.Payment.Settings;
|
||||
|
||||
public class PaymentSettingDefinitionProvider : SettingDefinitionProvider
|
||||
{
|
||||
public override void Define(ISettingDefinitionContext context)
|
||||
{
|
||||
//Define your own settings here. Example:
|
||||
//context.Add(new SettingDefinition(PaymentSettings.MySetting1));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
namespace KonSoft.Payment.Settings;
|
||||
|
||||
public static class PaymentSettings
|
||||
{
|
||||
private const string Prefix = "Payment";
|
||||
|
||||
//Add your own setting names here. Example:
|
||||
//public const string MySetting1 = Prefix + ".MySetting1";
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using KonSoft.Payment.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public class EntityFrameworkCorePaymentDbSchemaMigrator
|
||||
: IPaymentDbSchemaMigrator, ITransientDependency
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
|
||||
public EntityFrameworkCorePaymentDbSchemaMigrator(
|
||||
IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
}
|
||||
|
||||
public async Task MigrateAsync()
|
||||
{
|
||||
/* We intentionally resolve the PaymentDbContext
|
||||
* from IServiceProvider (instead of directly injecting it)
|
||||
* to properly get the connection string of the current tenant in the
|
||||
* current scope.
|
||||
*/
|
||||
|
||||
await _serviceProvider
|
||||
.GetRequiredService<PaymentDbContext>()
|
||||
.Database
|
||||
.MigrateAsync();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,86 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Volo.Abp.AuditLogging.EntityFrameworkCore;
|
||||
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Identity.EntityFrameworkCore;
|
||||
using Volo.Abp.OpenIddict.EntityFrameworkCore;
|
||||
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.TenantManagement;
|
||||
using Volo.Abp.TenantManagement.EntityFrameworkCore;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
[ReplaceDbContext(typeof(IIdentityDbContext))]
|
||||
[ReplaceDbContext(typeof(ITenantManagementDbContext))]
|
||||
[ConnectionStringName("Default")]
|
||||
public class PaymentDbContext :
|
||||
AbpDbContext<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)
|
||||
{
|
||||
base.OnModelCreating(builder);
|
||||
|
||||
/* Include modules to your migration db context */
|
||||
|
||||
builder.ConfigurePermissionManagement();
|
||||
builder.ConfigureSettingManagement();
|
||||
builder.ConfigureBackgroundJobs();
|
||||
builder.ConfigureAuditLogging();
|
||||
builder.ConfigureIdentity();
|
||||
builder.ConfigureOpenIddict();
|
||||
builder.ConfigureFeatureManagement();
|
||||
builder.ConfigureTenantManagement();
|
||||
|
||||
/* Configure your own tables/entities inside here */
|
||||
|
||||
//builder.Entity<YourEntity>(b =>
|
||||
//{
|
||||
// b.ToTable(PaymentConsts.DbTablePrefix + "YourEntities", PaymentConsts.DbSchema);
|
||||
// b.ConfigureByConvention(); //auto configure for the base class props
|
||||
// //...
|
||||
//});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Design;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
/* This class is needed for EF Core console commands
|
||||
* (like Add-Migration and Update-Database commands) */
|
||||
public class PaymentDbContextFactory : IDesignTimeDbContextFactory<PaymentDbContext>
|
||||
{
|
||||
public PaymentDbContext CreateDbContext(string[] args)
|
||||
{
|
||||
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
|
||||
PaymentEfCoreEntityExtensionMappings.Configure();
|
||||
|
||||
var configuration = BuildConfiguration();
|
||||
|
||||
var builder = new DbContextOptionsBuilder<PaymentDbContext>()
|
||||
.UseNpgsql(configuration.GetConnectionString("Default"));
|
||||
|
||||
return new PaymentDbContext(builder.Options);
|
||||
}
|
||||
|
||||
private static IConfigurationRoot BuildConfiguration()
|
||||
{
|
||||
var builder = new ConfigurationBuilder()
|
||||
.SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../KonSoft.Payment.DbMigrator/"))
|
||||
.AddJsonFile("appsettings.json", optional: false);
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.ObjectExtending;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public static class PaymentEfCoreEntityExtensionMappings
|
||||
{
|
||||
private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner();
|
||||
|
||||
public static void Configure()
|
||||
{
|
||||
PaymentGlobalFeatureConfigurator.Configure();
|
||||
PaymentModuleExtensionConfigurator.Configure();
|
||||
|
||||
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:
|
||||
|
||||
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
|
||||
*/
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.AuditLogging.EntityFrameworkCore;
|
||||
using Volo.Abp.BackgroundJobs.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore.PostgreSql;
|
||||
using Volo.Abp.FeatureManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.Identity.EntityFrameworkCore;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.OpenIddict.EntityFrameworkCore;
|
||||
using Volo.Abp.PermissionManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.SettingManagement.EntityFrameworkCore;
|
||||
using Volo.Abp.TenantManagement.EntityFrameworkCore;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentDomainModule),
|
||||
typeof(AbpIdentityEntityFrameworkCoreModule),
|
||||
typeof(AbpOpenIddictEntityFrameworkCoreModule),
|
||||
typeof(AbpPermissionManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpSettingManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpEntityFrameworkCorePostgreSqlModule),
|
||||
typeof(AbpBackgroundJobsEntityFrameworkCoreModule),
|
||||
typeof(AbpAuditLoggingEntityFrameworkCoreModule),
|
||||
typeof(AbpTenantManagementEntityFrameworkCoreModule),
|
||||
typeof(AbpFeatureManagementEntityFrameworkCoreModule)
|
||||
)]
|
||||
public class PaymentEntityFrameworkCoreModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
// https://www.npgsql.org/efcore/release-notes/6.0.html#opting-out-of-the-new-timestamp-mapping-logic
|
||||
AppContext.SetSwitch("Npgsql.EnableLegacyTimestampBehavior", true);
|
||||
|
||||
PaymentEfCoreEntityExtensionMappings.Configure();
|
||||
}
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddAbpDbContext<PaymentDbContext>(options =>
|
||||
{
|
||||
/* Remove "includeAllEntities: true" to create
|
||||
* default repositories only for aggregate roots */
|
||||
options.AddDefaultRepositories(includeAllEntities: true);
|
||||
});
|
||||
|
||||
Configure<AbpDbContextOptions>(options =>
|
||||
{
|
||||
/* The main point to change your DBMS.
|
||||
* See also PaymentMigrationsDbContextFactory for EF Core tooling. */
|
||||
options.UseNpgsql();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Payment.Domain\KonSoft.Payment.Domain.csproj" />
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.PostgreSql" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Identity.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.AuditLogging.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.EntityFrameworkCore" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.OpenIddict.EntityFrameworkCore" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
2006
modules/payment/src/KonSoft.Payment.EntityFrameworkCore/Migrations/20250908052440_Initial.Designer.cs
generated
Normal file
2006
modules/payment/src/KonSoft.Payment.EntityFrameworkCore/Migrations/20250908052440_Initial.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,2 @@
|
||||
using System.Runtime.CompilerServices;
|
||||
[assembly:InternalsVisibleToAttribute("KonSoft.Payment.EntityFrameworkCore.Tests")]
|
||||
@ -0,0 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Payment.Application.Contracts\KonSoft.Payment.Application.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Account.HttpApi.Client" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Identity.HttpApi.Client" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi.Client" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi.Client" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi.Client" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.HttpApi.Client" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="**\*generate-proxy.json" />
|
||||
<Content Remove="**\*generate-proxy.json" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,38 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp.Account;
|
||||
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.VirtualFileSystem;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentApplicationContractsModule),
|
||||
typeof(AbpAccountHttpApiClientModule),
|
||||
typeof(AbpIdentityHttpApiClientModule),
|
||||
typeof(AbpPermissionManagementHttpApiClientModule),
|
||||
typeof(AbpTenantManagementHttpApiClientModule),
|
||||
typeof(AbpFeatureManagementHttpApiClientModule),
|
||||
typeof(AbpSettingManagementHttpApiClientModule)
|
||||
)]
|
||||
public class PaymentHttpApiClientModule : AbpModule
|
||||
{
|
||||
public const string RemoteServiceName = "Default";
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
context.Services.AddHttpClientProxies(
|
||||
typeof(PaymentApplicationContractsModule).Assembly,
|
||||
RemoteServiceName
|
||||
);
|
||||
|
||||
Configure<AbpVirtualFileSystemOptions>(options =>
|
||||
{
|
||||
options.FileSets.AddEmbedded<PaymentHttpApiClientModule>();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using KonSoft.Payment.Localization;
|
||||
using Volo.Abp.AspNetCore.Mvc;
|
||||
|
||||
namespace KonSoft.Payment.Controllers;
|
||||
|
||||
/* Inherit your controllers from this class.
|
||||
*/
|
||||
public abstract class PaymentController : AbpControllerBase
|
||||
{
|
||||
protected PaymentController()
|
||||
{
|
||||
LocalizationResource = typeof(PaymentResource);
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\KonSoft.Payment.Application.Contracts\KonSoft.Payment.Application.Contracts.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Account.HttpApi" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Identity.HttpApi" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.PermissionManagement.HttpApi" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.TenantManagement.HttpApi" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.FeatureManagement.HttpApi" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.SettingManagement.HttpApi" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace KonSoft.Payment.Models.Test;
|
||||
|
||||
public class TestModel
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
|
||||
public DateTime BirthDate { get; set; }
|
||||
}
|
||||
@ -0,0 +1,41 @@
|
||||
using Localization.Resources.AbpUi;
|
||||
using KonSoft.Payment.Localization;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Localization;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.PermissionManagement.HttpApi;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.TenantManagement;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentApplicationContractsModule),
|
||||
typeof(AbpAccountHttpApiModule),
|
||||
typeof(AbpIdentityHttpApiModule),
|
||||
typeof(AbpPermissionManagementHttpApiModule),
|
||||
typeof(AbpTenantManagementHttpApiModule),
|
||||
typeof(AbpFeatureManagementHttpApiModule),
|
||||
typeof(AbpSettingManagementHttpApiModule)
|
||||
)]
|
||||
public class PaymentHttpApiModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
ConfigureLocalization();
|
||||
}
|
||||
|
||||
private void ConfigureLocalization()
|
||||
{
|
||||
Configure<AbpLocalizationOptions>(options =>
|
||||
{
|
||||
options.Resources
|
||||
.Get<PaymentResource>()
|
||||
.AddBaseTypes(
|
||||
typeof(AbpUiResource)
|
||||
);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\KonSoft.Payment.Application\KonSoft.Payment.Application.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Payment.Domain.Tests\KonSoft.Payment.Domain.Tests.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,9 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public abstract class PaymentApplicationTestBase<TStartupModule> : PaymentTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentApplicationModule),
|
||||
typeof(PaymentDomainTestModule)
|
||||
)]
|
||||
public class PaymentApplicationTestModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,34 @@
|
||||
using Shouldly;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.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 abstract class SampleAppServiceTests<TStartupModule> : PaymentApplicationTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
private readonly IIdentityUserAppService _userAppService;
|
||||
|
||||
protected 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");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\KonSoft.Payment.Domain\KonSoft.Payment.Domain.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Payment.TestBase\KonSoft.Payment.TestBase.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,10 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
/* Inherit from this class for your domain layer tests. */
|
||||
public abstract class PaymentDomainTestBase<TStartupModule> : PaymentTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentDomainModule),
|
||||
typeof(PaymentTestBaseModule)
|
||||
)]
|
||||
public class PaymentDomainTestModule : AbpModule
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,46 @@
|
||||
using System.Threading.Tasks;
|
||||
using Shouldly;
|
||||
using Volo.Abp.Identity;
|
||||
using Volo.Abp.Modularity;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.Samples;
|
||||
|
||||
/* This is just an example test class.
|
||||
* Normally, you don't test code of the modules you are using
|
||||
* (like IdentityUserManager here).
|
||||
* Only test your own domain services.
|
||||
*/
|
||||
public abstract class SampleDomainTests<TStartupModule> : PaymentDomainTestBase<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
private readonly IIdentityUserRepository _identityUserRepository;
|
||||
private readonly IdentityUserManager _identityUserManager;
|
||||
|
||||
protected SampleDomainTests()
|
||||
{
|
||||
_identityUserRepository = GetRequiredService<IIdentityUserRepository>();
|
||||
_identityUserManager = GetRequiredService<IdentityUserManager>();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Should_Set_Email_Of_A_User()
|
||||
{
|
||||
IdentityUser adminUser;
|
||||
|
||||
/* Need to manually start Unit Of Work because
|
||||
* FirstOrDefaultAsync should be executed while db connection / context is available.
|
||||
*/
|
||||
await WithUnitOfWorkAsync(async () =>
|
||||
{
|
||||
adminUser = await _identityUserRepository
|
||||
.FindByNormalizedUserNameAsync("ADMIN");
|
||||
|
||||
await _identityUserManager.SetEmailAsync(adminUser, "newemail@abp.io");
|
||||
await _identityUserRepository.UpdateAsync(adminUser);
|
||||
});
|
||||
|
||||
adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync("ADMIN");
|
||||
adminUser.Email.ShouldBe("newemail@abp.io");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
using KonSoft.Payment.Samples;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore.Applications;
|
||||
|
||||
[Collection(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class EfCoreSampleAppServiceTests : SampleAppServiceTests<PaymentEntityFrameworkCoreTestModule>
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,10 @@
|
||||
using KonSoft.Payment.Samples;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore.Domains;
|
||||
|
||||
[Collection(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class EfCoreSampleDomainTests : SampleDomainTests<PaymentEntityFrameworkCoreTestModule>
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
[CollectionDefinition(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class PaymentEntityFrameworkCoreCollection : ICollectionFixture<PaymentEntityFrameworkCoreFixture>
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,9 @@
|
||||
using KonSoft.Payment.EntityFrameworkCore;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public class PaymentEntityFrameworkCoreCollectionFixtureBase : ICollectionFixture<PaymentEntityFrameworkCoreFixture>
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,11 @@
|
||||
using System;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public class PaymentEntityFrameworkCoreFixture : IDisposable
|
||||
{
|
||||
public void Dispose()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,8 @@
|
||||
using Volo.Abp;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
public abstract class PaymentEntityFrameworkCoreTestBase : PaymentTestBase<PaymentEntityFrameworkCoreTestModule>
|
||||
{
|
||||
|
||||
}
|
||||
@ -0,0 +1,82 @@
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.EntityFrameworkCore.Storage;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.EntityFrameworkCore;
|
||||
using Volo.Abp.EntityFrameworkCore.Sqlite;
|
||||
using Volo.Abp.FeatureManagement;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.PermissionManagement;
|
||||
using Volo.Abp.SettingManagement;
|
||||
using Volo.Abp.Uow;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore;
|
||||
|
||||
[DependsOn(
|
||||
typeof(PaymentApplicationTestModule),
|
||||
typeof(PaymentEntityFrameworkCoreModule),
|
||||
typeof(AbpEntityFrameworkCoreSqliteModule)
|
||||
)]
|
||||
public class PaymentEntityFrameworkCoreTestModule : AbpModule
|
||||
{
|
||||
private SqliteConnection? _sqliteConnection;
|
||||
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<FeatureManagementOptions>(options =>
|
||||
{
|
||||
options.SaveStaticFeaturesToDatabase = false;
|
||||
options.IsDynamicFeatureStoreEnabled = false;
|
||||
});
|
||||
Configure<PermissionManagementOptions>(options =>
|
||||
{
|
||||
options.SaveStaticPermissionsToDatabase = false;
|
||||
options.IsDynamicPermissionStoreEnabled = false;
|
||||
});
|
||||
Configure<SettingManagementOptions>(options =>
|
||||
{
|
||||
options.SaveStaticSettingsToDatabase = false;
|
||||
options.IsDynamicSettingStoreEnabled = false;
|
||||
});
|
||||
context.Services.AddAlwaysDisableUnitOfWorkTransaction();
|
||||
|
||||
ConfigureInMemorySqlite(context.Services);
|
||||
}
|
||||
|
||||
private void ConfigureInMemorySqlite(IServiceCollection services)
|
||||
{
|
||||
_sqliteConnection = CreateDatabaseAndGetConnection();
|
||||
|
||||
services.Configure<AbpDbContextOptions>(options =>
|
||||
{
|
||||
options.Configure(context =>
|
||||
{
|
||||
context.DbContextOptions.UseSqlite(_sqliteConnection);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
public override void OnApplicationShutdown(ApplicationShutdownContext context)
|
||||
{
|
||||
_sqliteConnection?.Dispose();
|
||||
}
|
||||
|
||||
private static SqliteConnection CreateDatabaseAndGetConnection()
|
||||
{
|
||||
var connection = new AbpUnitTestSqliteConnection("Data Source=:memory:");
|
||||
connection.Open();
|
||||
|
||||
var options = new DbContextOptionsBuilder<PaymentDbContext>()
|
||||
.UseSqlite(connection)
|
||||
.Options;
|
||||
|
||||
using (var context = new PaymentDbContext(options))
|
||||
{
|
||||
context.GetService<IRelationalDatabaseCreator>().CreateTables();
|
||||
}
|
||||
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Domain.Repositories;
|
||||
using Volo.Abp.Identity;
|
||||
using Xunit;
|
||||
|
||||
namespace KonSoft.Payment.EntityFrameworkCore.Samples;
|
||||
|
||||
/* This is just an example test class.
|
||||
* Normally, you don't test ABP framework code
|
||||
* (like default AppUser repository IRepository<AppUser, Guid> here).
|
||||
* Only test your custom repository methods.
|
||||
*/
|
||||
[Collection(PaymentTestConsts.CollectionDefinitionName)]
|
||||
public class SampleRepositoryTests : PaymentEntityFrameworkCoreTestBase
|
||||
{
|
||||
private readonly IRepository<IdentityUser, Guid> _appUserRepository;
|
||||
|
||||
public SampleRepositoryTests()
|
||||
{
|
||||
_appUserRepository = GetRequiredService<IRepository<IdentityUser, Guid>>();
|
||||
}
|
||||
|
||||
[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.
|
||||
*/
|
||||
await WithUnitOfWorkAsync(async () =>
|
||||
{
|
||||
//Act
|
||||
var adminUser = await (await _appUserRepository.GetQueryableAsync())
|
||||
.Where(u => u.UserName == "admin")
|
||||
.FirstOrDefaultAsync();
|
||||
|
||||
//Assert
|
||||
adminUser.ShouldNotBeNull();
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\src\KonSoft.Payment.EntityFrameworkCore\KonSoft.Payment.EntityFrameworkCore.csproj" />
|
||||
<ProjectReference Include="..\KonSoft.Payment.Application.Tests\KonSoft.Payment.Application.Tests.csproj" />
|
||||
<PackageReference Include="Volo.Abp.EntityFrameworkCore.Sqlite" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Account;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
public class ClientDemoService : ITransientDependency
|
||||
{
|
||||
private readonly IProfileAppService _profileAppService;
|
||||
|
||||
public ClientDemoService(IProfileAppService profileAppService)
|
||||
{
|
||||
_profileAppService = profileAppService;
|
||||
}
|
||||
|
||||
public async Task RunAsync()
|
||||
{
|
||||
var output = await _profileAppService.GetAsync();
|
||||
Console.WriteLine($"UserName : {output.UserName}");
|
||||
Console.WriteLine($"Email : {output.Email}");
|
||||
Console.WriteLine($"Name : {output.Name}");
|
||||
Console.WriteLine($"Surname : {output.Surname}");
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,40 @@
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
|
||||
namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
public class ConsoleTestAppHostedService : IHostedService
|
||||
{
|
||||
private readonly IConfiguration _configuration;
|
||||
|
||||
public ConsoleTestAppHostedService(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
using (var application = await AbpApplicationFactory.CreateAsync<PaymentConsoleApiClientModule>(options =>
|
||||
{
|
||||
options.Services.ReplaceConfiguration(_configuration);
|
||||
options.UseAutofac();
|
||||
}))
|
||||
{
|
||||
await application.InitializeAsync();
|
||||
|
||||
var demo = application.ServiceProvider.GetRequiredService<ClientDemoService>();
|
||||
await demo.RunAsync();
|
||||
|
||||
await application.ShutdownAsync();
|
||||
}
|
||||
}
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,33 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="appsettings.json" />
|
||||
<Content Include="appsettings.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<None Remove="appsettings.secrets.json" />
|
||||
<Content Include="appsettings.secrets.json">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.Http.Client.IdentityModel" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" />
|
||||
<ProjectReference Include="..\..\src\KonSoft.Payment.HttpApi.Client\KonSoft.Payment.HttpApi.Client.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Polly;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.Http.Client;
|
||||
using Volo.Abp.Http.Client.IdentityModel;
|
||||
using Volo.Abp.Modularity;
|
||||
|
||||
namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(PaymentHttpApiClientModule),
|
||||
typeof(AbpHttpClientIdentityModelModule)
|
||||
)]
|
||||
public class PaymentConsoleApiClientModule : AbpModule
|
||||
{
|
||||
public override void PreConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
PreConfigure<AbpHttpClientBuilderOptions>(options =>
|
||||
{
|
||||
options.ProxyClientBuildActions.Add((remoteServiceName, clientBuilder) =>
|
||||
{
|
||||
clientBuilder.AddTransientHttpErrorPolicy(
|
||||
policyBuilder => policyBuilder.WaitAndRetryAsync(3, i => TimeSpan.FromSeconds(Math.Pow(2, i)))
|
||||
);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,22 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
|
||||
namespace KonSoft.Payment.HttpApi.Client.ConsoleTestApp;
|
||||
|
||||
class Program
|
||||
{
|
||||
static async Task Main(string[] args)
|
||||
{
|
||||
await CreateHostBuilder(args).RunConsoleAsync();
|
||||
}
|
||||
|
||||
public static IHostBuilder CreateHostBuilder(string[] args) =>
|
||||
Host.CreateDefaultBuilder(args)
|
||||
.AddAppSettingsSecretsJson()
|
||||
.ConfigureServices((hostContext, services) =>
|
||||
{
|
||||
services.AddHostedService<ConsoleTestAppHostedService>();
|
||||
});
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
{
|
||||
"RemoteServices": {
|
||||
"Default": {
|
||||
"BaseUrl": "https://localhost:44355"
|
||||
}
|
||||
},
|
||||
"IdentityClients": {
|
||||
"Default": {
|
||||
"GrantType": "password",
|
||||
"ClientId": "Payment_App",
|
||||
"UserName": "admin",
|
||||
"UserPassword": "1q2w3E*",
|
||||
"Authority": "https://localhost:44355",
|
||||
"Scope": "Payment"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,2 @@
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,31 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<Import Project="..\..\common.props" />
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<RootNamespace>KonSoft.Payment</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Volo.Abp.TestBase" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Autofac" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.Authorization" Version="8.3.4" />
|
||||
<PackageReference Include="Volo.Abp.BackgroundJobs.Abstractions" Version="8.3.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
||||
<PackageReference Include="NSubstitute" Version="5.1.0" />
|
||||
<PackageReference Include="NSubstitute.Analyzers.CSharp" Version="1.0.16">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="Shouldly" Version="4.2.1" />
|
||||
<PackageReference Include="xunit" Version="2.6.1" />
|
||||
<PackageReference Include="xunit.extensibility.execution" Version="2.6.1" />
|
||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -0,0 +1,60 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Uow;
|
||||
using Volo.Abp.Testing;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
/* All test classes are derived from this class, directly or indirectly.
|
||||
*/
|
||||
public abstract class PaymentTestBase<TStartupModule> : AbpIntegratedTest<TStartupModule>
|
||||
where TStartupModule : IAbpModule
|
||||
{
|
||||
protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options)
|
||||
{
|
||||
options.UseAutofac();
|
||||
}
|
||||
|
||||
protected virtual Task WithUnitOfWorkAsync(Func<Task> func)
|
||||
{
|
||||
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
|
||||
}
|
||||
|
||||
protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func<Task> action)
|
||||
{
|
||||
using (var scope = ServiceProvider.CreateScope())
|
||||
{
|
||||
var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
|
||||
|
||||
using (var uow = uowManager.Begin(options))
|
||||
{
|
||||
await action();
|
||||
|
||||
await uow.CompleteAsync();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual Task<TResult> WithUnitOfWorkAsync<TResult>(Func<Task<TResult>> func)
|
||||
{
|
||||
return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func);
|
||||
}
|
||||
|
||||
protected virtual async Task<TResult> WithUnitOfWorkAsync<TResult>(AbpUnitOfWorkOptions options, Func<Task<TResult>> func)
|
||||
{
|
||||
using (var scope = ServiceProvider.CreateScope())
|
||||
{
|
||||
var uowManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
|
||||
|
||||
using (var uow = uowManager.Begin(options))
|
||||
{
|
||||
var result = await func();
|
||||
await uow.CompleteAsync();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,47 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Volo.Abp;
|
||||
using Volo.Abp.Authorization;
|
||||
using Volo.Abp.Autofac;
|
||||
using Volo.Abp.BackgroundJobs;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.Modularity;
|
||||
using Volo.Abp.Threading;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
[DependsOn(
|
||||
typeof(AbpAutofacModule),
|
||||
typeof(AbpTestBaseModule),
|
||||
typeof(AbpAuthorizationModule),
|
||||
typeof(AbpBackgroundJobsAbstractionsModule)
|
||||
)]
|
||||
public class PaymentTestBaseModule : AbpModule
|
||||
{
|
||||
public override void ConfigureServices(ServiceConfigurationContext context)
|
||||
{
|
||||
Configure<AbpBackgroundJobOptions>(options =>
|
||||
{
|
||||
options.IsJobExecutionEnabled = false;
|
||||
});
|
||||
|
||||
context.Services.AddAlwaysAllowAuthorization();
|
||||
}
|
||||
|
||||
public override void OnApplicationInitialization(ApplicationInitializationContext context)
|
||||
{
|
||||
SeedTestData(context);
|
||||
}
|
||||
|
||||
private static void SeedTestData(ApplicationInitializationContext context)
|
||||
{
|
||||
AsyncHelper.RunSync(async () =>
|
||||
{
|
||||
using (var scope = context.ServiceProvider.CreateScope())
|
||||
{
|
||||
await scope.ServiceProvider
|
||||
.GetRequiredService<IDataSeeder>()
|
||||
.SeedAsync();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,6 @@
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public static class PaymentTestConsts
|
||||
{
|
||||
public const string CollectionDefinitionName = "Payment collection";
|
||||
}
|
||||
@ -0,0 +1,15 @@
|
||||
using System.Threading.Tasks;
|
||||
using Volo.Abp.Data;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
|
||||
namespace KonSoft.Payment;
|
||||
|
||||
public class PaymentTestDataSeedContributor : IDataSeedContributor, ITransientDependency
|
||||
{
|
||||
public Task SeedAsync(DataSeedContext context)
|
||||
{
|
||||
/* Seed additional test data... */
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,25 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Security.Claims;
|
||||
using Volo.Abp.DependencyInjection;
|
||||
using Volo.Abp.Security.Claims;
|
||||
|
||||
namespace KonSoft.Payment.Security;
|
||||
|
||||
[Dependency(ReplaceServices = true)]
|
||||
public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor
|
||||
{
|
||||
protected override ClaimsPrincipal GetClaimsPrincipal()
|
||||
{
|
||||
return GetPrincipal();
|
||||
}
|
||||
|
||||
private ClaimsPrincipal GetPrincipal()
|
||||
{
|
||||
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")
|
||||
}));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user