diff --git a/services/payment/EShopOnAbp.PaymentService.sln b/services/payment/EShopOnAbp.PaymentService.sln new file mode 100644 index 00000000..751c102c --- /dev/null +++ b/services/payment/EShopOnAbp.PaymentService.sln @@ -0,0 +1,116 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.31717.71 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.Domain.Shared", "src\EShopOnAbp.PaymentService.Domain.Shared\EShopOnAbp.PaymentService.Domain.Shared.csproj", "{D64C1577-4929-4B60-939E-96DE1534891A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.Domain", "src\EShopOnAbp.PaymentService.Domain\EShopOnAbp.PaymentService.Domain.csproj", "{F2840BC7-0188-4606-9126-DADD0F5ABF7A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.Application.Contracts", "src\EShopOnAbp.PaymentService.Application.Contracts\EShopOnAbp.PaymentService.Application.Contracts.csproj", "{BD65D04F-08D5-40C1-8C24-77CA0BACB877}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.Application", "src\EShopOnAbp.PaymentService.Application\EShopOnAbp.PaymentService.Application.csproj", "{78040F9E-3501-4A40-82DF-00A597710F35}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{649A3FFA-182F-4E56-9717-E6A9A2BEC545}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.EntityFrameworkCore", "src\EShopOnAbp.PaymentService.EntityFrameworkCore\EShopOnAbp.PaymentService.EntityFrameworkCore.csproj", "{0CE86223-D31D-4315-A1F5-87BA3EE1B844}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.HttpApi", "src\EShopOnAbp.PaymentService.HttpApi\EShopOnAbp.PaymentService.HttpApi.csproj", "{077AA5F8-8B61-420C-A6B5-0150A66FDB34}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.HttpApi.Client", "src\EShopOnAbp.PaymentService.HttpApi.Client\EShopOnAbp.PaymentService.HttpApi.Client.csproj", "{36E2735F-CEAB-44C8-A6D1-2CDAFF399751}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.TestBase", "test\EShopOnAbp.PaymentService.TestBase\EShopOnAbp.PaymentService.TestBase.csproj", "{C5BB573D-3030-4BCB-88B7-F6A85C32766C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.EntityFrameworkCore.Tests", "test\EShopOnAbp.PaymentService.EntityFrameworkCore.Tests\EShopOnAbp.PaymentService.EntityFrameworkCore.Tests.csproj", "{527F645C-C1FC-406E-8479-81386C8ECF13}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.Domain.Tests", "test\EShopOnAbp.PaymentService.Domain.Tests\EShopOnAbp.PaymentService.Domain.Tests.csproj", "{E60895E5-79C4-447D-88B7-85CB5BA336A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.Application.Tests", "test\EShopOnAbp.PaymentService.Application.Tests\EShopOnAbp.PaymentService.Application.Tests.csproj", "{90CB5DC4-C040-45C7-8900-9688B26405BC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp", "test\EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp\EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp.csproj", "{1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.PaymentService.HttpApi.Host", "src\EShopOnAbp.PaymentService.HttpApi.Host\EShopOnAbp.PaymentService.HttpApi.Host.csproj", "{DFC7C9C8-FBDF-4C34-B92F-1E31C3F561BD}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {D64C1577-4929-4B60-939E-96DE1534891A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D64C1577-4929-4B60-939E-96DE1534891A}.Release|Any CPU.Build.0 = Release|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F2840BC7-0188-4606-9126-DADD0F5ABF7A}.Release|Any CPU.Build.0 = Release|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BD65D04F-08D5-40C1-8C24-77CA0BACB877}.Release|Any CPU.Build.0 = Release|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Debug|Any CPU.Build.0 = Debug|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Release|Any CPU.ActiveCfg = Release|Any CPU + {78040F9E-3501-4A40-82DF-00A597710F35}.Release|Any CPU.Build.0 = Release|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Release|Any CPU.ActiveCfg = Release|Any CPU + {0CE86223-D31D-4315-A1F5-87BA3EE1B844}.Release|Any CPU.Build.0 = Release|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Debug|Any CPU.Build.0 = Debug|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Release|Any CPU.ActiveCfg = Release|Any CPU + {077AA5F8-8B61-420C-A6B5-0150A66FDB34}.Release|Any CPU.Build.0 = Release|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Debug|Any CPU.Build.0 = Debug|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Release|Any CPU.ActiveCfg = Release|Any CPU + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751}.Release|Any CPU.Build.0 = Release|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5BB573D-3030-4BCB-88B7-F6A85C32766C}.Release|Any CPU.Build.0 = Release|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Debug|Any CPU.Build.0 = Debug|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Release|Any CPU.ActiveCfg = Release|Any CPU + {527F645C-C1FC-406E-8479-81386C8ECF13}.Release|Any CPU.Build.0 = Release|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E60895E5-79C4-447D-88B7-85CB5BA336A4}.Release|Any CPU.Build.0 = Release|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Debug|Any CPU.Build.0 = Debug|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Release|Any CPU.ActiveCfg = Release|Any CPU + {90CB5DC4-C040-45C7-8900-9688B26405BC}.Release|Any CPU.Build.0 = Release|Any CPU + {1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8}.Release|Any CPU.Build.0 = Release|Any CPU + {DFC7C9C8-FBDF-4C34-B92F-1E31C3F561BD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DFC7C9C8-FBDF-4C34-B92F-1E31C3F561BD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DFC7C9C8-FBDF-4C34-B92F-1E31C3F561BD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DFC7C9C8-FBDF-4C34-B92F-1E31C3F561BD}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D64C1577-4929-4B60-939E-96DE1534891A} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {F2840BC7-0188-4606-9126-DADD0F5ABF7A} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {BD65D04F-08D5-40C1-8C24-77CA0BACB877} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {78040F9E-3501-4A40-82DF-00A597710F35} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {0CE86223-D31D-4315-A1F5-87BA3EE1B844} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {077AA5F8-8B61-420C-A6B5-0150A66FDB34} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {36E2735F-CEAB-44C8-A6D1-2CDAFF399751} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + {C5BB573D-3030-4BCB-88B7-F6A85C32766C} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {527F645C-C1FC-406E-8479-81386C8ECF13} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {E60895E5-79C4-447D-88B7-85CB5BA336A4} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {90CB5DC4-C040-45C7-8900-9688B26405BC} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8} = {CCD2960C-23CC-4AB4-B84D-60C7AAA52F4D} + {DFC7C9C8-FBDF-4C34-B92F-1E31C3F561BD} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6AAFA1C6-603E-13FA-45E5-7910AA9F661D} + EndGlobalSection +EndGlobal diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/EShopOnAbp.PaymentService.Application.Contracts.csproj b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/EShopOnAbp.PaymentService.Application.Contracts.csproj new file mode 100644 index 00000000..6ce4b39a --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/EShopOnAbp.PaymentService.Application.Contracts.csproj @@ -0,0 +1,16 @@ + + + + + + netstandard2.0 + EShopOnAbp.PaymentService + + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceApplicationContractsModule.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceApplicationContractsModule.cs new file mode 100644 index 00000000..b2a238f7 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceApplicationContractsModule.cs @@ -0,0 +1,16 @@ +using Volo.Abp.Application; +using Volo.Abp.Modularity; +using Volo.Abp.Authorization; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationModule) + )] + public class PaymentServiceApplicationContractsModule : AbpModule + { + + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceRemoteServiceConsts.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceRemoteServiceConsts.cs new file mode 100644 index 00000000..80d996e6 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/PaymentServiceRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace EShopOnAbp.PaymentService +{ + public class PaymentServiceRemoteServiceConsts + { + public const string RemoteServiceName = "PaymentService"; + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/Permissions/PaymentServicePermissionDefinitionProvider.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/Permissions/PaymentServicePermissionDefinitionProvider.cs new file mode 100644 index 00000000..5d28293c --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/Permissions/PaymentServicePermissionDefinitionProvider.cs @@ -0,0 +1,19 @@ +using EShopOnAbp.PaymentService.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace EShopOnAbp.PaymentService.Permissions +{ + public class PaymentServicePermissionDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var myGroup = context.AddGroup(PaymentServicePermissions.GroupName, L("Permission:PaymentService")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/Permissions/PaymentServicePermissions.cs b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/Permissions/PaymentServicePermissions.cs new file mode 100644 index 00000000..5926e3a2 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application.Contracts/Permissions/PaymentServicePermissions.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Reflection; + +namespace EShopOnAbp.PaymentService.Permissions +{ + public class PaymentServicePermissions + { + public const string GroupName = "PaymentService"; + + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(PaymentServicePermissions)); + } + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/EShopOnAbp.PaymentService.Application.csproj b/services/payment/src/EShopOnAbp.PaymentService.Application/EShopOnAbp.PaymentService.Application.csproj new file mode 100644 index 00000000..87c15c28 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/EShopOnAbp.PaymentService.Application.csproj @@ -0,0 +1,17 @@ + + + + + + netstandard2.0 + EShopOnAbp.PaymentService + + + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceAppService.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceAppService.cs new file mode 100644 index 00000000..9593f93f --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceAppService.cs @@ -0,0 +1,14 @@ +using EShopOnAbp.PaymentService.Localization; +using Volo.Abp.Application.Services; + +namespace EShopOnAbp.PaymentService +{ + public abstract class PaymentServiceAppService : ApplicationService + { + protected PaymentServiceAppService() + { + LocalizationResource = typeof(PaymentServiceResource); + ObjectMapperContext = typeof(PaymentServiceApplicationModule); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceApplicationAutoMapperProfile.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceApplicationAutoMapperProfile.cs new file mode 100644 index 00000000..0867269d --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceApplicationAutoMapperProfile.cs @@ -0,0 +1,14 @@ +using AutoMapper; + +namespace EShopOnAbp.PaymentService +{ + public class PaymentServiceApplicationAutoMapperProfile : Profile + { + public PaymentServiceApplicationAutoMapperProfile() + { + /* You can configure your AutoMapper mapping configuration here. + * Alternatively, you can split your mapping configurations + * into multiple profile classes for a better organization. */ + } + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceApplicationModule.cs b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceApplicationModule.cs new file mode 100644 index 00000000..6bbac237 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Application/PaymentServiceApplicationModule.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; +using Volo.Abp.Application; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceDomainModule), + typeof(PaymentServiceApplicationContractsModule), + typeof(AbpDddApplicationModule), + typeof(AbpAutoMapperModule) + )] + public class PaymentServiceApplicationModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddMaps(validate: true); + }); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/EShopOnAbp.PaymentService.Domain.Shared.csproj b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/EShopOnAbp.PaymentService.Domain.Shared.csproj new file mode 100644 index 00000000..de87538d --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/EShopOnAbp.PaymentService.Domain.Shared.csproj @@ -0,0 +1,24 @@ + + + + + + netstandard2.0 + EShopOnAbp.PaymentService + true + + + + + + + + + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/ar.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/ar.json new file mode 100644 index 00000000..f3bdc3d2 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/ar.json @@ -0,0 +1,7 @@ +{ + "culture": "ar", + "texts": { + "MyAccount": "إدارة ملفى", + "SamplePageMessage": "صفحة نموذجية للوحدة النمطية PaymentService" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/cs.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/cs.json new file mode 100644 index 00000000..ec24874b --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/cs.json @@ -0,0 +1,7 @@ +{ + "culture": "cs", + "texts": { + "MyAccount": "Spravovat profil", + "SamplePageMessage": "Ukázková stránka pro modul PaymentService" + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/de-DE.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/de-DE.json new file mode 100644 index 00000000..407a8b89 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/de-DE.json @@ -0,0 +1,7 @@ +{ + "culture": "de-DE", + "texts": { + "MyAccount": "Mein Konto", + "SamplePageMessage": "Eine Beispielseite für das Modul PaymentServiceModul" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/en-GB.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/en-GB.json new file mode 100644 index 00000000..8fd7feff --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/en-GB.json @@ -0,0 +1,7 @@ +{ + "culture": "en-GB", + "texts": { + "MyAccount": "My account", + "SamplePageMessage": "A sample page for the PaymentService module" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/en.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/en.json new file mode 100644 index 00000000..1d7761b9 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/en.json @@ -0,0 +1,7 @@ +{ + "culture": "en", + "texts": { + "MyAccount": "My account", + "SamplePageMessage": "A sample page for the PaymentService module" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/es.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/es.json new file mode 100644 index 00000000..dae12cc6 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/es.json @@ -0,0 +1,7 @@ +{ + "culture": "es", + "texts": { + "MyAccount": "Mi cuenta", + "SamplePageMessage": "Una página de ejemplo para el módulo PaymentService " + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/fi.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/fi.json new file mode 100644 index 00000000..8484ad11 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/fi.json @@ -0,0 +1,7 @@ +{ + "culture": "fi", + "texts": { + "MyAccount": "Tilini", + "SamplePageMessage": "Esimerkkisivu PaymentService-moduulille" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/fr.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/fr.json new file mode 100644 index 00000000..95f10267 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/fr.json @@ -0,0 +1,7 @@ +{ + "culture": "fr", + "texts": { + "MyAccount": "Mon compte", + "SamplePageMessage": "Exemple de page pour le module PaymentService" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/hi.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/hi.json new file mode 100644 index 00000000..1b75028c --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/hi.json @@ -0,0 +1,7 @@ +{ + "culture": "hi", + "texts": { + "MyAccount": "मेरा खाता", + "SamplePageMessage": "PaymentService मॉड्यूल के लिए एक नमूना पृष्ठ" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/hu.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/hu.json new file mode 100644 index 00000000..ea1244fa --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/hu.json @@ -0,0 +1,7 @@ +{ + "culture": "hu", + "texts": { + "MyAccount": "A fiókom", + "SamplePageMessage": "Mintaoldal a PaymentService modulhoz" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/it.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/it.json new file mode 100644 index 00000000..06e6a000 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/it.json @@ -0,0 +1,7 @@ +{ + "culture": "it", + "texts": { + "MyAccount": "Il mio conto", + "SamplePageMessage": "Una pagina di esempio per il modulo PaymentService" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/nl.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/nl.json new file mode 100644 index 00000000..d84b6d68 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/nl.json @@ -0,0 +1,7 @@ +{ + "culture": "nl", + "texts": { + "MyAccount": "Mijn rekening", + "SamplePageMessage": "Een voorbeeldpagina voor de PaymentService module" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/pl-PL.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/pl-PL.json new file mode 100644 index 00000000..3ea7b190 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/pl-PL.json @@ -0,0 +1,6 @@ +{ + "culture": "pl-PL", + "texts": { + + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/pt-BR.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/pt-BR.json new file mode 100644 index 00000000..6d746df0 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/pt-BR.json @@ -0,0 +1,6 @@ +{ + "culture": "pt-BR", + "texts": { + + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/ro-RO.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/ro-RO.json new file mode 100644 index 00000000..bd160155 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/ro-RO.json @@ -0,0 +1,7 @@ +{ + "culture": "ro-RO", + "texts": { + "MyAccount": "Contul meu", + "SamplePageMessage": "Un exemplu de pagină pentru modululul PaymentService" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/sk.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/sk.json new file mode 100644 index 00000000..e8f27bad --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/sk.json @@ -0,0 +1,6 @@ +{ + "culture": "sk", + "texts": { + "SamplePageMessage": "Ukážka stránky pre modul PaymentService" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/sl.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/sl.json new file mode 100644 index 00000000..229c449b --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/sl.json @@ -0,0 +1,6 @@ +{ + "culture": "sl", + "texts": { + "MyAccount": "Moj račun" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/tr.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/tr.json new file mode 100644 index 00000000..2dde3484 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/tr.json @@ -0,0 +1,7 @@ +{ + "culture": "tr", + "texts": { + "MyAccount": "Hesabım", + "SamplePageMessage": "PaymentService modulünden örnek bir sayfa" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/vi.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/vi.json new file mode 100644 index 00000000..d8eb5f3c --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/vi.json @@ -0,0 +1,6 @@ +{ + "culture": "vi", + "texts": { + + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/zh-Hans.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/zh-Hans.json new file mode 100644 index 00000000..179bc6a8 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/zh-Hans.json @@ -0,0 +1,7 @@ +{ + "culture": "zh-Hans", + "texts": { + "MyAccount": "我的账户", + "SamplePageMessage": "PaymentService模块的示例页面" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/zh-Hant.json b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/zh-Hant.json new file mode 100644 index 00000000..699d31ef --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentService/zh-Hant.json @@ -0,0 +1,6 @@ +{ + "culture": "zh-Hant", + "texts": { + "MyAccount": "我的賬戶" + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentServiceResource.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentServiceResource.cs new file mode 100644 index 00000000..4fc46597 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/Localization/PaymentServiceResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace EShopOnAbp.PaymentService.Localization +{ + [LocalizationResourceName("PaymentService")] + public class PaymentServiceResource + { + + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentServiceDomainSharedModule.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentServiceDomainSharedModule.cs new file mode 100644 index 00000000..1ab5de4d --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentServiceDomainSharedModule.cs @@ -0,0 +1,37 @@ +using Volo.Abp.Modularity; +using Volo.Abp.Localization; +using EShopOnAbp.PaymentService.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Validation; +using Volo.Abp.Validation.Localization; +using Volo.Abp.VirtualFileSystem; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(AbpValidationModule) + )] + public class PaymentServiceDomainSharedModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/PaymentService"); + }); + + Configure(options => + { + options.MapCodeNamespace("PaymentService", typeof(PaymentServiceResource)); + }); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentServiceErrorCodes.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentServiceErrorCodes.cs new file mode 100644 index 00000000..a1d7debf --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain.Shared/PaymentServiceErrorCodes.cs @@ -0,0 +1,7 @@ +namespace EShopOnAbp.PaymentService +{ + public static class PaymentServiceErrorCodes + { + //Add your business exception error codes here... + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain/EShopOnAbp.PaymentService.Domain.csproj b/services/payment/src/EShopOnAbp.PaymentService.Domain/EShopOnAbp.PaymentService.Domain.csproj new file mode 100644 index 00000000..96a20f9e --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain/EShopOnAbp.PaymentService.Domain.csproj @@ -0,0 +1,15 @@ + + + + + + netstandard2.0 + EShopOnAbp.PaymentService + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentServiceDbProperties.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentServiceDbProperties.cs new file mode 100644 index 00000000..c5e7f369 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentServiceDbProperties.cs @@ -0,0 +1,11 @@ +namespace EShopOnAbp.PaymentService +{ + public static class PaymentServiceDbProperties + { + public static string DbTablePrefix { get; set; } = "PaymentService"; + + public static string DbSchema { get; set; } = null; + + public const string ConnectionStringName = "PaymentService"; + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentServiceDomainModule.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentServiceDomainModule.cs new file mode 100644 index 00000000..56f50482 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain/PaymentServiceDomainModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Domain; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(AbpDddDomainModule), + typeof(PaymentServiceDomainSharedModule) + )] + public class PaymentServiceDomainModule : AbpModule + { + + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain/Settings/PaymentServiceSettingDefinitionProvider.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain/Settings/PaymentServiceSettingDefinitionProvider.cs new file mode 100644 index 00000000..1ce50784 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain/Settings/PaymentServiceSettingDefinitionProvider.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Settings; + +namespace EShopOnAbp.PaymentService.Settings +{ + public class PaymentServiceSettingDefinitionProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + /* Define module settings here. + * Use names from PaymentServiceSettings class. + */ + } + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.Domain/Settings/PaymentServiceSettings.cs b/services/payment/src/EShopOnAbp.PaymentService.Domain/Settings/PaymentServiceSettings.cs new file mode 100644 index 00000000..6a026811 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.Domain/Settings/PaymentServiceSettings.cs @@ -0,0 +1,11 @@ +namespace EShopOnAbp.PaymentService.Settings +{ + public static class PaymentServiceSettings + { + public const string GroupName = "PaymentService"; + + /* Add constants for setting names. Example: + * public const string MySettingName = GroupName + ".MySettingName"; + */ + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EShopOnAbp.PaymentService.EntityFrameworkCore.csproj b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EShopOnAbp.PaymentService.EntityFrameworkCore.csproj new file mode 100644 index 00000000..9fc8d5fd --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EShopOnAbp.PaymentService.EntityFrameworkCore.csproj @@ -0,0 +1,22 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + + + + + + + + + + runtime; build; native; contentfiles; analyzers + compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/IPaymentServiceDbContext.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/IPaymentServiceDbContext.cs new file mode 100644 index 00000000..44f56d19 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/IPaymentServiceDbContext.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + [ConnectionStringName(PaymentServiceDbProperties.ConnectionStringName)] + public interface IPaymentServiceDbContext : IEfCoreDbContext + { + /* Add DbSet for each Aggregate Root here. Example: + * DbSet Questions { get; } + */ + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContext.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContext.cs new file mode 100644 index 00000000..cab4c878 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContext.cs @@ -0,0 +1,48 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + [ConnectionStringName(PaymentServiceDbProperties.ConnectionStringName)] + public class PaymentServiceDbContext : + AbpDbContext + { + /* Add DbSet properties for your Aggregate Roots / Entities here. */ + + /* 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. + */ + + public PaymentServiceDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + /* Include modules to your migration db context */ + + builder.ConfigurePaymentService(); + + /* Configure your own tables/entities inside here */ + + //builder.Entity(b => + //{ + // b.ToTable(PaymentServiceConsts.DbTablePrefix + "YourEntities", PaymentServiceConsts.DbSchema); + // b.ConfigureByConvention(); //auto configure for the base class props + // //... + //}); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextFactory.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextFactory.cs new file mode 100644 index 00000000..fa4e7ab8 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextFactory.cs @@ -0,0 +1,33 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + /* This class is needed for EF Core console commands + * (like Add-Migration and Update-Database commands) */ + public class PaymentServiceDbContextFactory : IDesignTimeDbContextFactory + { + public PaymentServiceDbContext CreateDbContext(string[] args) + { + PaymentServiceEfCoreEntityExtensionMappings.Configure(); + + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); + + return new PaymentServiceDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../EShopOnAbp.PaymentService.HttpApi.Host/")) + .AddJsonFile("appsettings.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs new file mode 100644 index 00000000..963dc838 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceDbContextModelCreatingExtensions.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + public static class PaymentServiceDbContextModelCreatingExtensions + { + public static void ConfigurePaymentService( + this ModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + + /* Configure all entities here. Example: + + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(PaymentServiceDbProperties.DbTablePrefix + "Questions", PaymentServiceDbProperties.DbSchema); + + b.ConfigureByConvention(); + + //Properties + b.Property(q => q.Title).IsRequired().HasMaxLength(QuestionConsts.MaxTitleLength); + + //Relations + b.HasMany(question => question.Tags).WithOne().HasForeignKey(qt => qt.QuestionId); + + //Indexes + b.HasIndex(q => q.CreationTime); + }); + */ + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceEfCoreEntityExtensionMappings.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceEfCoreEntityExtensionMappings.cs new file mode 100644 index 00000000..bf850c7c --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceEfCoreEntityExtensionMappings.cs @@ -0,0 +1,39 @@ +using Volo.Abp.Threading; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + public static class PaymentServiceEfCoreEntityExtensionMappings + { + private static readonly OneTimeRunner OneTimeRunner = new OneTimeRunner(); + + public static void 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 PaymentServiceModuleExtensionConfigurator 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( + "MyProperty", + (entityBuilder, propertyBuilder) => + { + propertyBuilder.HasMaxLength(128); + } + ); + + * See the documentation for more: + * https://docs.abp.io/en/abp/latest/Customizing-Application-Modules-Extending-Entities + */ + }); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreModule.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreModule.cs new file mode 100644 index 00000000..9e1ee693 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreModule.cs @@ -0,0 +1,36 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + [DependsOn( + typeof(PaymentServiceDomainModule), + typeof(AbpEntityFrameworkCoreSqlServerModule) + )] + public class PaymentServiceEntityFrameworkCoreModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PaymentServiceEfCoreEntityExtensionMappings.Configure(); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAbpDbContext(options => + { + /* Remove "includeAllEntities: true" to create + * default repositories only for aggregate roots */ + options.AddDefaultRepositories(includeAllEntities: true); + }); + + Configure(options => + { + /* The main point to change your DBMS. + * See also PaymentServiceMigrationsDbContextFactory for EF Core tooling. */ + options.UseSqlServer(); + }); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Properties/AssemblyInfo.cs b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..cc7e1c5c --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.EntityFrameworkCore/Properties/AssemblyInfo.cs @@ -0,0 +1,2 @@ +using System.Runtime.CompilerServices; +[assembly:InternalsVisibleToAttribute("EShopOnAbp.PaymentService.EntityFrameworkCore.Tests")] diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/PaymentService-generate-proxy.json b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/PaymentService-generate-proxy.json new file mode 100644 index 00000000..cf60aca6 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/PaymentService-generate-proxy.json @@ -0,0 +1,53 @@ +{ + "modules": { + "PaymentService": { + "rootPath": "PaymentService", + "remoteServiceName": "PaymentService", + "controllers": { + "EShopOnAbp.PaymentService.Samples.SampleController": { + "controllerName": "Sample", + "controllerGroupName": "Sample", + "type": "EShopOnAbp.PaymentService.Samples.SampleController", + "interfaces": [ + { + "type": "EShopOnAbp.PaymentService.Samples.ISampleAppService" + } + ], + "actions": { + "GetAsync": { + "uniqueName": "GetAsync", + "name": "GetAsync", + "httpMethod": "GET", + "url": "api/PaymentService/sample", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "EShopOnAbp.PaymentService.Samples.SampleDto", + "typeSimple": "EShopOnAbp.PaymentService.Samples.SampleDto" + }, + "allowAnonymous": null, + "implementFrom": "EShopOnAbp.PaymentService.Samples.ISampleAppService" + }, + "GetAuthorizedAsync": { + "uniqueName": "GetAuthorizedAsync", + "name": "GetAuthorizedAsync", + "httpMethod": "GET", + "url": "api/PaymentService/sample/authorized", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "EShopOnAbp.PaymentService.Samples.SampleDto", + "typeSimple": "EShopOnAbp.PaymentService.Samples.SampleDto" + }, + "allowAnonymous": false, + "implementFrom": "EShopOnAbp.PaymentService.Samples.ISampleAppService" + } + } + } + } + } + }, + "types": {} +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs new file mode 100644 index 00000000..c1eda3e6 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs @@ -0,0 +1,15 @@ +// This file is automatically generated by ABP framework to use MVC Controllers from CSharp +using System; +using System.Threading.Tasks; +using Volo.Abp.Application.Dtos; +using Volo.Abp.Http.Client; +using Volo.Abp.Http.Modeling; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Http.Client.ClientProxying; +using EShopOnAbp.PaymentService.Samples; + +// ReSharper disable once CheckNamespace +namespace EShopOnAbp.PaymentService.Samples.ClientProxies +{ + +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/SampleClientProxy.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/SampleClientProxy.cs new file mode 100644 index 00000000..63e60b1d --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/ClientProxies/SampleClientProxy.cs @@ -0,0 +1,8 @@ +// This file is part of SampleClientProxy, you can customize it here +// ReSharper disable once CheckNamespace +namespace EShopOnAbp.PaymentService.Samples.ClientProxies +{ + public partial class SampleClientProxy + { + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/EShopOnAbp.PaymentService.HttpApi.Client.csproj b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/EShopOnAbp.PaymentService.HttpApi.Client.csproj new file mode 100644 index 00000000..7fe1af2d --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/EShopOnAbp.PaymentService.HttpApi.Client.csproj @@ -0,0 +1,20 @@ + + + + + + netstandard2.0 + EShopOnAbp.PaymentService + + + + + + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/PaymentServiceHttpApiClientModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/PaymentServiceHttpApiClientModule.cs new file mode 100644 index 00000000..8645e369 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Client/PaymentServiceHttpApiClientModule.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceApplicationContractsModule), + typeof(AbpHttpClientModule))] + public class PaymentServiceHttpApiClientModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddStaticHttpClientProxies( + typeof(PaymentServiceApplicationContractsModule).Assembly, + PaymentServiceRemoteServiceConsts.RemoteServiceName + ); + + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Controllers/HomeController.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Controllers/HomeController.cs new file mode 100644 index 00000000..23718617 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Controllers/HomeController.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; + +namespace EShopOnAbp.PaymentService.Controllers +{ + public class HomeController : AbpController + { + public ActionResult Index() + { + return Redirect("~/swagger"); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs new file mode 100644 index 00000000..d771e75f --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationChecker.cs @@ -0,0 +1,31 @@ +using EShopOnAbp.PaymentService.EntityFrameworkCore; +using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Uow; + +namespace EShopOnAbp.PaymentService.DbMigrations +{ + public class PaymentServiceDatabaseMigrationChecker : PendingMigrationsCheckerBase + { + public PaymentServiceDatabaseMigrationChecker( + IUnitOfWorkManager unitOfWorkManager, + IServiceProvider serviceProvider, + ICurrentTenant currentTenant, + IDistributedEventBus distributedEventBus) + : base( + unitOfWorkManager, + serviceProvider, + currentTenant, + distributedEventBus, + PaymentServiceDbProperties.ConnectionStringName) + { + + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs new file mode 100644 index 00000000..067f0019 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/DbMigrations/PaymentServiceDatabaseMigrationEventHandler.cs @@ -0,0 +1,49 @@ +using EShopOnAbp.PaymentService.EntityFrameworkCore; +using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations; +using System; +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TenantManagement; +using Volo.Abp.Uow; + +namespace EShopOnAbp.PaymentService.DbMigrations +{ + public class PaymentServiceDatabaseMigrationEventHandler + : DatabaseMigrationEventHandlerBase, + IDistributedEventHandler + { + public PaymentServiceDatabaseMigrationEventHandler( + ICurrentTenant currentTenant, + IUnitOfWorkManager unitOfWorkManager, + ITenantStore tenantStore, + ITenantRepository tenantRepository, + IDistributedEventBus distributedEventBus, + string databaseName) : base(currentTenant, unitOfWorkManager, tenantStore, tenantRepository, distributedEventBus, databaseName) + { + } + + public async Task HandleEventAsync(ApplyDatabaseMigrationsEto eventData) + { + if (eventData.DatabaseName != DatabaseName) + { + return; + } + + if (eventData.TenantId != null) + { + return; + } + + try + { + await MigrateDatabaseSchemaAsync(null); + } + catch (Exception ex) + { + await HandleErrorOnApplyDatabaseMigrationAsync(eventData, ex); + } + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj new file mode 100644 index 00000000..c1c7f3e1 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/EShopOnAbp.PaymentService.HttpApi.Host.csproj @@ -0,0 +1,29 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + true + EShopOnAbp.PaymentService-c2d31439-b723-48e2-b061-5ebd7aeb6010 + + + + + + + + + + + + + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs new file mode 100644 index 00000000..d5d956ba --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/PaymentServiceHttpApiHostModule.cs @@ -0,0 +1,108 @@ +using EShopOnAbp.PaymentService.EntityFrameworkCore; +using EShopOnAbp.Shared.Hosting.Microservices; +using Microsoft.AspNetCore.Builder; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using Volo.Abp; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using EShopOnAbp.Shared.Hosting.AspNetCore; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; +using System.Collections.Generic; +using System; +using EShopOnAbp.PaymentService.DbMigrations; +using System.Linq; +using Microsoft.AspNetCore.Cors; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceApplicationModule), + typeof(PaymentServiceEntityFrameworkCoreModule), + typeof(PaymentServiceHttpApiModule) + )] + public class PaymentServiceHttpApiHostModule : AbpModule + { + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + JwtBearerConfigurationHelper.Configure(context, "CatalogService"); + // SwaggerConfigurationHelper.Configure(context, "Catalog Service API"); + + SwaggerWithAuthConfigurationHelper.Configure( + context: context, + authority: configuration["AuthServer:Authority"], + scopes: new Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ + { + {"CatalogService", "Catalog Service API"}, + }, + apiTitle: "Catalog Service API" + ); + + context.Services.AddCors(options => + { + options.AddDefaultPolicy(builder => + { + builder + .WithOrigins( + configuration["App:CorsOrigins"] + .Split(",", StringSplitOptions.RemoveEmptyEntries) + .Select(o => o.Trim().RemovePostFix("/")) + .ToArray() + ) + .WithAbpExposedHeaders() + .SetIsOriginAllowedToAllowWildcardSubdomains() + .AllowAnyHeader() + .AllowAnyMethod() + .AllowCredentials(); + }); + }); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + var app = context.GetApplicationBuilder(); + var env = context.GetEnvironment(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + + app.UseCorrelationId(); + app.UseCors(); + app.UseAbpRequestLocalization(); + app.UseStaticFiles(); + app.UseRouting(); + // app.UseHttpMetrics(); + app.UseAuthentication(); + app.UseAbpClaimsMap(); + app.UseMultiTenancy(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseSwaggerUI(options => { options.SwaggerEndpoint("/swagger/v1/swagger.json", "Saas Service API"); }); + app.UseAbpSerilogEnrichers(); + app.UseAuditing(); + app.UseUnitOfWork(); + app.UseConfiguredEndpoints(endpoints => + { + // endpoints.MapMetrics(); + }); + } + + public override void OnPostApplicationInitialization(ApplicationInitializationContext context) + { + using (var scope = context.ServiceProvider.CreateScope()) + { + AsyncHelper.RunSync( + () => scope.ServiceProvider + .GetRequiredService() + .CheckAsync() + ); + } + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Program.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Program.cs new file mode 100644 index 00000000..326df981 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Program.cs @@ -0,0 +1,56 @@ +using System; +using System.IO; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Hosting; +using Serilog; +using Serilog.Events; + +namespace EShopOnAbp.PaymentService +{ + public class Program + { + public static int Main(string[] args) + { + Log.Logger = new LoggerConfiguration() +#if DEBUG + .MinimumLevel.Debug() +#else + .MinimumLevel.Information() +#endif + .MinimumLevel.Override("Microsoft", LogEventLevel.Information) + .Enrich.FromLogContext() + .WriteTo.Async(c => c.File("Logs/logs.txt")) +#if DEBUG + .WriteTo.Async(c => c.Console()) +#endif + .CreateLogger(); + + try + { + Log.Information("Starting web host."); + CreateHostBuilder(args).Build().Run(); + return 0; + } + catch (Exception ex) + { + Log.Fatal(ex, "Host terminated unexpectedly!"); + return 1; + } + finally + { + Log.CloseAndFlush(); + } + } + + internal static IHostBuilder CreateHostBuilder(string[] args) => + Host.CreateDefaultBuilder(args) + .AddAppSettingsSecretsJson() + .ConfigureWebHostDefaults(webBuilder => + { + webBuilder.UseStartup(); + }) + .UseAutofac() + .UseSerilog(); + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Properties/launchSettings.json b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Properties/launchSettings.json new file mode 100644 index 00000000..e5d34b88 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:44347", + "sslPort": 44347 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "EShopOnAbp.PaymentService.DemoApp": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "https://localhost:44347", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Startup.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Startup.cs new file mode 100644 index 00000000..57212ab9 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/Startup.cs @@ -0,0 +1,21 @@ +using System; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace EShopOnAbp.PaymentService +{ + public class Startup + { + public void ConfigureServices(IServiceCollection services) + { + services.AddApplication(); + } + + public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) + { + app.InitializeApplication(); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json new file mode 100644 index 00000000..226ea038 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.json @@ -0,0 +1,18 @@ +{ + "App": { + "CorsOrigins": "https://*.PaymentService.com,http://localhost:4200,http://localhost:44307,https://localhost:44307" + }, + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=PaymentService_Main;Trusted_Connection=True", + "PaymentService": "Server=(LocalDb)\\MSSQLLocalDB;Database=PaymentService_Module;Trusted_Connection=True" + }, + "Redis": { + "Configuration": "127.0.0.1" + }, + "AuthServer": { + "Authority": "https://localhost:44362/", + "RequireHttpsMetadata": "false", + "SwaggerClientId": "PaymentService_Swagger", + "SwaggerClientSecret": "1q2w3e*" + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.secrets.json b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.secrets.json new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi.Host/appsettings.secrets.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi/EShopOnAbp.PaymentService.HttpApi.csproj b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/EShopOnAbp.PaymentService.HttpApi.csproj new file mode 100644 index 00000000..9c5888d6 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/EShopOnAbp.PaymentService.HttpApi.csproj @@ -0,0 +1,15 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + + + + + + + + diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi/PaymentServiceController.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/PaymentServiceController.cs new file mode 100644 index 00000000..6a6dd493 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/PaymentServiceController.cs @@ -0,0 +1,13 @@ +using EShopOnAbp.PaymentService.Localization; +using Volo.Abp.AspNetCore.Mvc; + +namespace EShopOnAbp.PaymentService +{ + public abstract class PaymentServiceController : AbpControllerBase + { + protected PaymentServiceController() + { + LocalizationResource = typeof(PaymentServiceResource); + } + } +} diff --git a/services/payment/src/EShopOnAbp.PaymentService.HttpApi/PaymentServiceHttpApiModule.cs b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/PaymentServiceHttpApiModule.cs new file mode 100644 index 00000000..772f3042 --- /dev/null +++ b/services/payment/src/EShopOnAbp.PaymentService.HttpApi/PaymentServiceHttpApiModule.cs @@ -0,0 +1,33 @@ +using Localization.Resources.AbpUi; +using EShopOnAbp.PaymentService.Localization; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Microsoft.Extensions.DependencyInjection; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] + public class PaymentServiceHttpApiModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(PaymentServiceHttpApiModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); + } + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/EShopOnAbp.PaymentService.Application.Tests.csproj b/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/EShopOnAbp.PaymentService.Application.Tests.csproj new file mode 100644 index 00000000..110632e8 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/EShopOnAbp.PaymentService.Application.Tests.csproj @@ -0,0 +1,16 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + + + + + + + + + diff --git a/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/PaymentServiceApplicationTestBase.cs b/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/PaymentServiceApplicationTestBase.cs new file mode 100644 index 00000000..d87fe8b5 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/PaymentServiceApplicationTestBase.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.PaymentService +{ + /* Inherit from this class for your application layer tests. + * See SampleAppService_Tests for example. + */ + public abstract class PaymentServiceApplicationTestBase : PaymentServiceTestBase + { + + } +} \ No newline at end of file diff --git a/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/PaymentServiceApplicationTestModule.cs b/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/PaymentServiceApplicationTestModule.cs new file mode 100644 index 00000000..bc8fe5aa --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.Application.Tests/PaymentServiceApplicationTestModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Modularity; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceApplicationModule), + typeof(PaymentServiceDomainTestModule) + )] + public class PaymentServiceApplicationTestModule : AbpModule + { + + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/EShopOnAbp.PaymentService.Domain.Tests.csproj b/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/EShopOnAbp.PaymentService.Domain.Tests.csproj new file mode 100644 index 00000000..feb9fd14 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/EShopOnAbp.PaymentService.Domain.Tests.csproj @@ -0,0 +1,15 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + + + + + + + + diff --git a/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/PaymentServiceDomainTestBase.cs b/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/PaymentServiceDomainTestBase.cs new file mode 100644 index 00000000..9e47f536 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/PaymentServiceDomainTestBase.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.PaymentService +{ + /* Inherit from this class for your domain layer tests. + * See SampleManager_Tests for example. + */ + public abstract class PaymentServiceDomainTestBase : PaymentServiceTestBase + { + + } +} \ No newline at end of file diff --git a/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/PaymentServiceDomainTestModule.cs b/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/PaymentServiceDomainTestModule.cs new file mode 100644 index 00000000..379580de --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.Domain.Tests/PaymentServiceDomainTestModule.cs @@ -0,0 +1,17 @@ +using EShopOnAbp.PaymentService.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.PaymentService +{ + /* Domain tests are configured to use the EF Core provider. + * You can switch to MongoDB, however your domain tests should be + * database independent anyway. + */ + [DependsOn( + typeof(PaymentServiceEntityFrameworkCoreTestModule) + )] + public class PaymentServiceDomainTestModule : AbpModule + { + + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests.csproj b/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests.csproj new file mode 100644 index 00000000..1b92399b --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests.csproj @@ -0,0 +1,18 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + + + + + + + + + + + diff --git a/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreTestBase.cs b/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreTestBase.cs new file mode 100644 index 00000000..1eed46c2 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreTestBase.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + /* This class can be used as a base class for EF Core integration tests, + * while SampleRepository_Tests uses a different approach. + */ + public abstract class PaymentServiceEntityFrameworkCoreTestBase : PaymentServiceTestBase + { + + } +} \ No newline at end of file diff --git a/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreTestModule.cs b/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreTestModule.cs new file mode 100644 index 00000000..82b62a8b --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.EntityFrameworkCore.Tests/EntityFrameworkCore/PaymentServiceEntityFrameworkCoreTestModule.cs @@ -0,0 +1,43 @@ +using Microsoft.Data.Sqlite; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Storage; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.Sqlite; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.PaymentService.EntityFrameworkCore +{ + [DependsOn( + typeof(PaymentServiceTestBaseModule), + typeof(PaymentServiceEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqliteModule) + )] + public class PaymentServiceEntityFrameworkCoreTestModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + var sqliteConnection = CreateDatabaseAndGetConnection(); + + Configure(options => + { + options.Configure(abpDbContextConfigurationContext => + { + abpDbContextConfigurationContext.DbContextOptions.UseSqlite(sqliteConnection); + }); + }); + } + + private static SqliteConnection CreateDatabaseAndGetConnection() + { + var connection = new SqliteConnection("Data Source=:memory:"); + connection.Open(); + + new PaymentServiceDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); + + return connection; + } + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs new file mode 100644 index 00000000..f127d0d3 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -0,0 +1,146 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using IdentityModel.Client; +using Microsoft.Extensions.Configuration; +using Volo.Abp.DependencyInjection; +using Volo.Abp.IdentityModel; + +namespace EShopOnAbp.PaymentService +{ + public class ClientDemoService : ITransientDependency + { + private readonly IIdentityModelAuthenticationService _authenticationService; + private readonly IConfiguration _configuration; + + public ClientDemoService( + IIdentityModelAuthenticationService authenticationService, + IConfiguration configuration) + { + _authenticationService = authenticationService; + _configuration = configuration; + } + + public async Task RunAsync() + { + await TestWithDynamicProxiesAsync(); + await TestWithHttpClientAndIdentityModelAuthenticationServiceAsync(); + await TestAllManuallyAsync(); + } + + /* Shows how to perform an HTTP request to the API using ABP's dynamic c# proxy + * feature. It is just simple as calling a local service method. + * Authorization and HTTP request details are handled by the ABP framework. + */ + private async Task TestWithDynamicProxiesAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithDynamicProxiesAsync)} *****"); + } + + /* Shows how to use HttpClient to perform a request to the HTTP API. + * It uses ABP's IIdentityModelAuthenticationService to simplify obtaining access tokens. + */ + private async Task TestWithHttpClientAndIdentityModelAuthenticationServiceAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestWithHttpClientAndIdentityModelAuthenticationServiceAsync)} *****"); + + //Get access token using ABP's IIdentityModelAuthenticationService + + var accessToken = await _authenticationService.GetAccessTokenAsync( + new IdentityClientConfiguration( + _configuration["IdentityClients:Default:Authority"], + _configuration["IdentityClients:Default:Scope"], + _configuration["IdentityClients:Default:ClientId"], + _configuration["IdentityClients:Default:ClientSecret"], + _configuration["IdentityClients:Default:GrantType"], + _configuration["IdentityClients:Default:UserName"], + _configuration["IdentityClients:Default:UserPassword"] + ) + ); + + //Perform the actual HTTP request + + using (var httpClient = new HttpClient()) + { + httpClient.SetBearerToken(accessToken); + + var url = _configuration["RemoteServices:PaymentService:BaseUrl"] + + "api/PaymentService/sample/authorized"; + + var responseMessage = await httpClient.GetAsync(url); + if (responseMessage.IsSuccessStatusCode) + { + var responseString = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine("Result: " + responseString); + } + else + { + throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); + } + } + } + + /* Shows how to use HttpClient to perform a request to the HTTP API. + * It obtains access token using IdentityServer's API. See its documentation: + * https://identityserver4.readthedocs.io/en/latest/quickstarts/2_resource_owner_passwords.html + */ + private async Task TestAllManuallyAsync() + { + Console.WriteLine(); + Console.WriteLine($"***** {nameof(TestAllManuallyAsync)} *****"); + + //Obtain access token from the IDS4 server + + // discover endpoints from metadata + var client = new HttpClient(); + var disco = await client.GetDiscoveryDocumentAsync(_configuration["IdentityClients:Default:Authority"]); + if (disco.IsError) + { + Console.WriteLine(disco.Error); + return; + } + + // request token + var tokenResponse = await client.RequestPasswordTokenAsync(new PasswordTokenRequest + { + Address = disco.TokenEndpoint, + ClientId = _configuration["IdentityClients:Default:ClientId"], + ClientSecret = _configuration["IdentityClients:Default:ClientSecret"], + UserName = _configuration["IdentityClients:Default:UserName"], + Password = _configuration["IdentityClients:Default:UserPassword"], + Scope = _configuration["IdentityClients:Default:Scope"] + }); + + if (tokenResponse.IsError) + { + Console.WriteLine(tokenResponse.Error); + return; + } + + Console.WriteLine(tokenResponse.Json); + + //Perform the actual HTTP request + + using (var httpClient = new HttpClient()) + { + httpClient.SetBearerToken(tokenResponse.AccessToken); + + var url = _configuration["RemoteServices:PaymentService:BaseUrl"] + + "api/PaymentService/sample/authorized"; + + var responseMessage = await httpClient.GetAsync(url); + if (responseMessage.IsSuccessStatusCode) + { + var responseString = await responseMessage.Content.ReadAsStringAsync(); + Console.WriteLine("Result: " + responseString); + } + else + { + throw new Exception("Remote server returns error code: " + responseMessage.StatusCode); + } + } + } + } +} \ No newline at end of file diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs new file mode 100644 index 00000000..b6b8da9e --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs @@ -0,0 +1,37 @@ +using Microsoft.Extensions.Hosting; +using System.Threading; +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; + +namespace EShopOnAbp.PaymentService.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 = AbpApplicationFactory.Create(options=> + { + options.Services.ReplaceConfiguration(_configuration); + })) + { + application.Initialize(); + + var demo = application.ServiceProvider.GetRequiredService(); + await demo.RunAsync(); + + application.Shutdown(); + } + } + + public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp.csproj b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp.csproj new file mode 100644 index 00000000..d18fdb86 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp.csproj @@ -0,0 +1,31 @@ + + + + Exe + net6.0 + EShopOnAbp.PaymentService + + + + + + + + + + + PreserveNewest + Always + + + + PreserveNewest + Always + + + + + + + + diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/PaymentServiceConsoleApiClientModule.cs b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/PaymentServiceConsoleApiClientModule.cs new file mode 100644 index 00000000..5ad360f0 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/PaymentServiceConsoleApiClientModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Http.Client.IdentityModel; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(PaymentServiceHttpApiClientModule), + typeof(AbpHttpClientIdentityModelModule) + )] + public class PaymentServiceConsoleApiClientModule : AbpModule + { + + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/Program.cs b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/Program.cs new file mode 100644 index 00000000..85cd7fce --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/Program.cs @@ -0,0 +1,23 @@ +using System.Threading.Tasks; +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; + +namespace EShopOnAbp.PaymentService.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(); + }); + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/appsettings.json b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/appsettings.json new file mode 100644 index 00000000..a75fbfed --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/appsettings.json @@ -0,0 +1,21 @@ +{ + "RemoteServices": { + "Default": { + "BaseUrl": "https://localhost:44362/" + }, + "PaymentService": { + "BaseUrl": "https://localhost:44347/" + } + }, + "IdentityClients": { + "Default": { + "GrantType": "password", + "ClientId": "PaymentService_App", + "ClientSecret": "1q2w3e*", + "UserName": "admin", + "UserPassword": "1q2w3E*", + "Authority": "https://localhost:44362/", + "Scope": "PaymentService" + } + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/services/payment/test/EShopOnAbp.PaymentService.TestBase/EShopOnAbp.PaymentService.TestBase.csproj b/services/payment/test/EShopOnAbp.PaymentService.TestBase/EShopOnAbp.PaymentService.TestBase.csproj new file mode 100644 index 00000000..3bc97cd7 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.TestBase/EShopOnAbp.PaymentService.TestBase.csproj @@ -0,0 +1,23 @@ + + + + + + net6.0 + EShopOnAbp.PaymentService + + + + + + + + + + + + + + + + diff --git a/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceDataSeedContributor.cs b/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceDataSeedContributor.cs new file mode 100644 index 00000000..24654029 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceDataSeedContributor.cs @@ -0,0 +1,33 @@ +using System.Threading.Tasks; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; +using Volo.Abp.MultiTenancy; + +namespace EShopOnAbp.PaymentService +{ + public class PaymentServiceDataSeedContributor : IDataSeedContributor, ITransientDependency + { + private readonly IGuidGenerator _guidGenerator; + private readonly ICurrentTenant _currentTenant; + + public PaymentServiceDataSeedContributor( + IGuidGenerator guidGenerator, ICurrentTenant currentTenant) + { + _guidGenerator = guidGenerator; + _currentTenant = currentTenant; + } + + public Task SeedAsync(DataSeedContext context) + { + /* Instead of returning the Task.CompletedTask, you can insert your test data + * at this point! + */ + + using (_currentTenant.Change(context?.TenantId)) + { + return Task.CompletedTask; + } + } + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceTestBase.cs b/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceTestBase.cs new file mode 100644 index 00000000..0d0d42b5 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceTestBase.cs @@ -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 EShopOnAbp.PaymentService +{ + /* All test classes are derived from this class, directly or indirectly. */ + public abstract class PaymentServiceTestBase : AbpIntegratedTest + where TStartupModule : IAbpModule + { + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) + { + options.UseAutofac(); + } + + protected virtual Task WithUnitOfWorkAsync(Func func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } + + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func action) + { + using (var scope = ServiceProvider.CreateScope()) + { + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) + { + await action(); + + await uow.CompleteAsync(); + } + } + } + + protected virtual Task WithUnitOfWorkAsync(Func> func) + { + return WithUnitOfWorkAsync(new AbpUnitOfWorkOptions(), func); + } + + protected virtual async Task WithUnitOfWorkAsync(AbpUnitOfWorkOptions options, Func> func) + { + using (var scope = ServiceProvider.CreateScope()) + { + var uowManager = scope.ServiceProvider.GetRequiredService(); + + using (var uow = uowManager.Begin(options)) + { + var result = await func(); + await uow.CompleteAsync(); + return result; + } + } + } + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceTestBaseModule.cs b/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceTestBaseModule.cs new file mode 100644 index 00000000..079ea545 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.TestBase/PaymentServiceTestBaseModule.cs @@ -0,0 +1,42 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp; +using Volo.Abp.Authorization; +using Volo.Abp.Autofac; +using Volo.Abp.Data; +using Volo.Abp.Modularity; +using Volo.Abp.Threading; + +namespace EShopOnAbp.PaymentService +{ + [DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(PaymentServiceDomainModule) + )] + public class PaymentServiceTestBaseModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + 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() + .SeedAsync(); + } + }); + } + } +} diff --git a/services/payment/test/EShopOnAbp.PaymentService.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/services/payment/test/EShopOnAbp.PaymentService.TestBase/Security/FakeCurrentPrincipalAccessor.cs new file mode 100644 index 00000000..ccd8aad9 --- /dev/null +++ b/services/payment/test/EShopOnAbp.PaymentService.TestBase/Security/FakeCurrentPrincipalAccessor.cs @@ -0,0 +1,43 @@ +using System.Collections.Generic; +using System.Security.Claims; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Security.Claims; + +namespace EShopOnAbp.PaymentService.Security +{ + [Dependency(ReplaceServices = true)] + public class FakeCurrentPrincipalAccessor : ThreadCurrentPrincipalAccessor + { + protected override ClaimsPrincipal GetClaimsPrincipal() + { + return GetPrincipal(); + } + + private ClaimsPrincipal _principal; + + private ClaimsPrincipal GetPrincipal() + { + if (_principal == null) + { + lock (this) + { + if (_principal == null) + { + _principal = new ClaimsPrincipal( + new ClaimsIdentity( + new List + { + new Claim(AbpClaimTypes.UserId,"2e701e62-0953-4dd3-910b-dc6cc93ccb0d"), + new Claim(AbpClaimTypes.UserName,"admin"), + new Claim(AbpClaimTypes.Email,"admin@abp.io") + } + ) + ); + } + } + } + + return _principal; + } + } +}