diff --git a/services/ordering/EShopOnAbp.OrderingService.sln b/services/ordering/EShopOnAbp.OrderingService.sln new file mode 100644 index 00000000..3767d965 --- /dev/null +++ b/services/ordering/EShopOnAbp.OrderingService.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.OrderingService.Domain.Shared", "src\EShopOnAbp.OrderingService.Domain.Shared\EShopOnAbp.OrderingService.Domain.Shared.csproj", "{D64C1577-4929-4B60-939E-96DE1534891A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.Domain", "src\EShopOnAbp.OrderingService.Domain\EShopOnAbp.OrderingService.Domain.csproj", "{F2840BC7-0188-4606-9126-DADD0F5ABF7A}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.Application.Contracts", "src\EShopOnAbp.OrderingService.Application.Contracts\EShopOnAbp.OrderingService.Application.Contracts.csproj", "{BD65D04F-08D5-40C1-8C24-77CA0BACB877}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.Application", "src\EShopOnAbp.OrderingService.Application\EShopOnAbp.OrderingService.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.OrderingService.EntityFrameworkCore", "src\EShopOnAbp.OrderingService.EntityFrameworkCore\EShopOnAbp.OrderingService.EntityFrameworkCore.csproj", "{0CE86223-D31D-4315-A1F5-87BA3EE1B844}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.HttpApi", "src\EShopOnAbp.OrderingService.HttpApi\EShopOnAbp.OrderingService.HttpApi.csproj", "{077AA5F8-8B61-420C-A6B5-0150A66FDB34}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.HttpApi.Client", "src\EShopOnAbp.OrderingService.HttpApi.Client\EShopOnAbp.OrderingService.HttpApi.Client.csproj", "{36E2735F-CEAB-44C8-A6D1-2CDAFF399751}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.TestBase", "test\EShopOnAbp.OrderingService.TestBase\EShopOnAbp.OrderingService.TestBase.csproj", "{C5BB573D-3030-4BCB-88B7-F6A85C32766C}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.EntityFrameworkCore.Tests", "test\EShopOnAbp.OrderingService.EntityFrameworkCore.Tests\EShopOnAbp.OrderingService.EntityFrameworkCore.Tests.csproj", "{527F645C-C1FC-406E-8479-81386C8ECF13}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.Domain.Tests", "test\EShopOnAbp.OrderingService.Domain.Tests\EShopOnAbp.OrderingService.Domain.Tests.csproj", "{E60895E5-79C4-447D-88B7-85CB5BA336A4}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.Application.Tests", "test\EShopOnAbp.OrderingService.Application.Tests\EShopOnAbp.OrderingService.Application.Tests.csproj", "{90CB5DC4-C040-45C7-8900-9688B26405BC}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp", "test\EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp\EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp.csproj", "{1EDCD6D4-DF3A-4E3B-ABB6-C0D0B373EAB8}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.OrderingService.HttpApi.Host", "src\EShopOnAbp.OrderingService.HttpApi.Host\EShopOnAbp.OrderingService.HttpApi.Host.csproj", "{714836C5-CFB1-4E29-BD1D-E2C9017A139D}" +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 + {714836C5-CFB1-4E29-BD1D-E2C9017A139D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {714836C5-CFB1-4E29-BD1D-E2C9017A139D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {714836C5-CFB1-4E29-BD1D-E2C9017A139D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {714836C5-CFB1-4E29-BD1D-E2C9017A139D}.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} + {714836C5-CFB1-4E29-BD1D-E2C9017A139D} = {649A3FFA-182F-4E56-9717-E6A9A2BEC545} + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {6AAFA1C6-603E-13FA-45E5-7910AA9F661D} + EndGlobalSection +EndGlobal diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/EShopOnAbp.OrderingService.Application.Contracts.csproj b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/EShopOnAbp.OrderingService.Application.Contracts.csproj new file mode 100644 index 00000000..dbd7eb07 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/EShopOnAbp.OrderingService.Application.Contracts.csproj @@ -0,0 +1,16 @@ + + + + + + netstandard2.0 + EShopOnAbp.OrderingService + + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs new file mode 100644 index 00000000..b4b42c8f --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceApplicationContractsModule.cs @@ -0,0 +1,16 @@ +using Volo.Abp.Application; +using Volo.Abp.Modularity; +using Volo.Abp.Authorization; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceDomainSharedModule), + typeof(AbpDddApplicationContractsModule), + typeof(AbpAuthorizationModule) + )] + public class OrderingServiceApplicationContractsModule : AbpModule + { + + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs new file mode 100644 index 00000000..6d7a1e67 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/OrderingServiceRemoteServiceConsts.cs @@ -0,0 +1,7 @@ +namespace EShopOnAbp.OrderingService +{ + public class OrderingServiceRemoteServiceConsts + { + public const string RemoteServiceName = "OrderingService"; + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissionDefinitionProvider.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissionDefinitionProvider.cs new file mode 100644 index 00000000..b1aeeee3 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissionDefinitionProvider.cs @@ -0,0 +1,19 @@ +using EShopOnAbp.OrderingService.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace EShopOnAbp.OrderingService.Permissions +{ + public class OrderingServicePermissionDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var myGroup = context.AddGroup(OrderingServicePermissions.GroupName, L("Permission:OrderingService")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs new file mode 100644 index 00000000..779f1a41 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application.Contracts/Permissions/OrderingServicePermissions.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Reflection; + +namespace EShopOnAbp.OrderingService.Permissions +{ + public class OrderingServicePermissions + { + public const string GroupName = "OrderingService"; + + public static string[] GetAll() + { + return ReflectionHelper.GetPublicConstantsRecursively(typeof(OrderingServicePermissions)); + } + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application/EShopOnAbp.OrderingService.Application.csproj b/services/ordering/src/EShopOnAbp.OrderingService.Application/EShopOnAbp.OrderingService.Application.csproj new file mode 100644 index 00000000..c352dca2 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/EShopOnAbp.OrderingService.Application.csproj @@ -0,0 +1,17 @@ + + + + + + netstandard2.0 + EShopOnAbp.OrderingService + + + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceAppService.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceAppService.cs new file mode 100644 index 00000000..3234e0be --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceAppService.cs @@ -0,0 +1,14 @@ +using EShopOnAbp.OrderingService.Localization; +using Volo.Abp.Application.Services; + +namespace EShopOnAbp.OrderingService +{ + public abstract class OrderingServiceAppService : ApplicationService + { + protected OrderingServiceAppService() + { + LocalizationResource = typeof(OrderingServiceResource); + ObjectMapperContext = typeof(OrderingServiceApplicationModule); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationAutoMapperProfile.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationAutoMapperProfile.cs new file mode 100644 index 00000000..965a1899 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationAutoMapperProfile.cs @@ -0,0 +1,14 @@ +using AutoMapper; + +namespace EShopOnAbp.OrderingService +{ + public class OrderingServiceApplicationAutoMapperProfile : Profile + { + public OrderingServiceApplicationAutoMapperProfile() + { + /* 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/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs new file mode 100644 index 00000000..47e5d2ff --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Application/OrderingServiceApplicationModule.cs @@ -0,0 +1,25 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.AutoMapper; +using Volo.Abp.Modularity; +using Volo.Abp.Application; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceDomainModule), + typeof(OrderingServiceApplicationContractsModule), + typeof(AbpDddApplicationModule), + typeof(AbpAutoMapperModule) + )] + public class OrderingServiceApplicationModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddAutoMapperObjectMapper(); + Configure(options => + { + options.AddMaps(validate: true); + }); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/EShopOnAbp.OrderingService.Domain.Shared.csproj b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/EShopOnAbp.OrderingService.Domain.Shared.csproj new file mode 100644 index 00000000..e238c380 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/EShopOnAbp.OrderingService.Domain.Shared.csproj @@ -0,0 +1,24 @@ + + + + + + netstandard2.0 + EShopOnAbp.OrderingService + true + + + + + + + + + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/ar.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/ar.json new file mode 100644 index 00000000..5fc8b36c --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/ar.json @@ -0,0 +1,7 @@ +{ + "culture": "ar", + "texts": { + "MyAccount": "إدارة ملفى", + "SamplePageMessage": "صفحة نموذجية للوحدة النمطية OrderingService" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/cs.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/cs.json new file mode 100644 index 00000000..04b91e6f --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/cs.json @@ -0,0 +1,7 @@ +{ + "culture": "cs", + "texts": { + "MyAccount": "Spravovat profil", + "SamplePageMessage": "Ukázková stránka pro modul OrderingService" + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/de-DE.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/de-DE.json new file mode 100644 index 00000000..eefb9fb2 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/de-DE.json @@ -0,0 +1,7 @@ +{ + "culture": "de-DE", + "texts": { + "MyAccount": "Mein Konto", + "SamplePageMessage": "Eine Beispielseite für das Modul OrderingServiceModul" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en-GB.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en-GB.json new file mode 100644 index 00000000..a221b110 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en-GB.json @@ -0,0 +1,7 @@ +{ + "culture": "en-GB", + "texts": { + "MyAccount": "My account", + "SamplePageMessage": "A sample page for the OrderingService module" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en.json new file mode 100644 index 00000000..7ab4c6d7 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/en.json @@ -0,0 +1,7 @@ +{ + "culture": "en", + "texts": { + "MyAccount": "My account", + "SamplePageMessage": "A sample page for the OrderingService module" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/es.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/es.json new file mode 100644 index 00000000..5d3effa4 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/es.json @@ -0,0 +1,7 @@ +{ + "culture": "es", + "texts": { + "MyAccount": "Mi cuenta", + "SamplePageMessage": "Una página de ejemplo para el módulo OrderingService " + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/fi.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/fi.json new file mode 100644 index 00000000..257f9b41 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/fi.json @@ -0,0 +1,7 @@ +{ + "culture": "fi", + "texts": { + "MyAccount": "Tilini", + "SamplePageMessage": "Esimerkkisivu OrderingService-moduulille" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/fr.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/fr.json new file mode 100644 index 00000000..ae97d843 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/fr.json @@ -0,0 +1,7 @@ +{ + "culture": "fr", + "texts": { + "MyAccount": "Mon compte", + "SamplePageMessage": "Exemple de page pour le module OrderingService" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/hi.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/hi.json new file mode 100644 index 00000000..c565fe32 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/hi.json @@ -0,0 +1,7 @@ +{ + "culture": "hi", + "texts": { + "MyAccount": "मेरा खाता", + "SamplePageMessage": "OrderingService मॉड्यूल के लिए एक नमूना पृष्ठ" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/hu.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/hu.json new file mode 100644 index 00000000..145c1117 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/hu.json @@ -0,0 +1,7 @@ +{ + "culture": "hu", + "texts": { + "MyAccount": "A fiókom", + "SamplePageMessage": "Mintaoldal a OrderingService modulhoz" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/it.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/it.json new file mode 100644 index 00000000..0370117f --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/it.json @@ -0,0 +1,7 @@ +{ + "culture": "it", + "texts": { + "MyAccount": "Il mio conto", + "SamplePageMessage": "Una pagina di esempio per il modulo OrderingService" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/nl.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/nl.json new file mode 100644 index 00000000..ece1e4b4 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/nl.json @@ -0,0 +1,7 @@ +{ + "culture": "nl", + "texts": { + "MyAccount": "Mijn rekening", + "SamplePageMessage": "Een voorbeeldpagina voor de OrderingService module" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/pl-PL.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/pl-PL.json new file mode 100644 index 00000000..3ea7b190 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/pl-PL.json @@ -0,0 +1,6 @@ +{ + "culture": "pl-PL", + "texts": { + + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/pt-BR.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/pt-BR.json new file mode 100644 index 00000000..6d746df0 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/pt-BR.json @@ -0,0 +1,6 @@ +{ + "culture": "pt-BR", + "texts": { + + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/ro-RO.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/ro-RO.json new file mode 100644 index 00000000..0d8ab7c8 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/ro-RO.json @@ -0,0 +1,7 @@ +{ + "culture": "ro-RO", + "texts": { + "MyAccount": "Contul meu", + "SamplePageMessage": "Un exemplu de pagină pentru modululul OrderingService" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/sk.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/sk.json new file mode 100644 index 00000000..0727e940 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/sk.json @@ -0,0 +1,6 @@ +{ + "culture": "sk", + "texts": { + "SamplePageMessage": "Ukážka stránky pre modul OrderingService" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/sl.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/sl.json new file mode 100644 index 00000000..229c449b --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/sl.json @@ -0,0 +1,6 @@ +{ + "culture": "sl", + "texts": { + "MyAccount": "Moj račun" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/tr.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/tr.json new file mode 100644 index 00000000..07159dad --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/tr.json @@ -0,0 +1,7 @@ +{ + "culture": "tr", + "texts": { + "MyAccount": "Hesabım", + "SamplePageMessage": "OrderingService modulünden örnek bir sayfa" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/vi.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/vi.json new file mode 100644 index 00000000..d8eb5f3c --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/vi.json @@ -0,0 +1,6 @@ +{ + "culture": "vi", + "texts": { + + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/zh-Hans.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/zh-Hans.json new file mode 100644 index 00000000..53f4f377 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/zh-Hans.json @@ -0,0 +1,7 @@ +{ + "culture": "zh-Hans", + "texts": { + "MyAccount": "我的账户", + "SamplePageMessage": "OrderingService模块的示例页面" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/zh-Hant.json b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/zh-Hant.json new file mode 100644 index 00000000..699d31ef --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingService/zh-Hant.json @@ -0,0 +1,6 @@ +{ + "culture": "zh-Hant", + "texts": { + "MyAccount": "我的賬戶" + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs new file mode 100644 index 00000000..cc7f7121 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/Localization/OrderingServiceResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace EShopOnAbp.OrderingService.Localization +{ + [LocalizationResourceName("OrderingService")] + public class OrderingServiceResource + { + + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs new file mode 100644 index 00000000..51121b33 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceDomainSharedModule.cs @@ -0,0 +1,37 @@ +using Volo.Abp.Modularity; +using Volo.Abp.Localization; +using EShopOnAbp.OrderingService.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Validation; +using Volo.Abp.Validation.Localization; +using Volo.Abp.VirtualFileSystem; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(AbpValidationModule) + )] + public class OrderingServiceDomainSharedModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/OrderingService"); + }); + + Configure(options => + { + options.MapCodeNamespace("OrderingService", typeof(OrderingServiceResource)); + }); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceErrorCodes.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceErrorCodes.cs new file mode 100644 index 00000000..dae0f837 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain.Shared/OrderingServiceErrorCodes.cs @@ -0,0 +1,7 @@ +namespace EShopOnAbp.OrderingService +{ + public static class OrderingServiceErrorCodes + { + //Add your business exception error codes here... + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/EShopOnAbp.OrderingService.Domain.csproj b/services/ordering/src/EShopOnAbp.OrderingService.Domain/EShopOnAbp.OrderingService.Domain.csproj new file mode 100644 index 00000000..d213e41d --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/EShopOnAbp.OrderingService.Domain.csproj @@ -0,0 +1,15 @@ + + + + + + netstandard2.0 + EShopOnAbp.OrderingService + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs new file mode 100644 index 00000000..61451e62 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDbProperties.cs @@ -0,0 +1,11 @@ +namespace EShopOnAbp.OrderingService +{ + public static class OrderingServiceDbProperties + { + public static string DbTablePrefix { get; set; } = ""; + + public static string DbSchema { get; set; } + + public const string ConnectionStringName = "OrderingService"; + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs new file mode 100644 index 00000000..c2634e07 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/OrderingServiceDomainModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Domain; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(AbpDddDomainModule), + typeof(OrderingServiceDomainSharedModule) + )] + public class OrderingServiceDomainModule : AbpModule + { + + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs new file mode 100644 index 00000000..ac0284a3 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettingDefinitionProvider.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Settings; + +namespace EShopOnAbp.OrderingService.Settings +{ + public class OrderingServiceSettingDefinitionProvider : SettingDefinitionProvider + { + public override void Define(ISettingDefinitionContext context) + { + /* Define module settings here. + * Use names from OrderingServiceSettings class. + */ + } + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs new file mode 100644 index 00000000..f1346cc9 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.Domain/Settings/OrderingServiceSettings.cs @@ -0,0 +1,11 @@ +namespace EShopOnAbp.OrderingService.Settings +{ + public static class OrderingServiceSettings + { + public const string GroupName = "OrderingService"; + + /* Add constants for setting names. Example: + * public const string MySettingName = GroupName + ".MySettingName"; + */ + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EShopOnAbp.OrderingService.EntityFrameworkCore.csproj b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EShopOnAbp.OrderingService.EntityFrameworkCore.csproj new file mode 100644 index 00000000..61fb80d3 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EShopOnAbp.OrderingService.EntityFrameworkCore.csproj @@ -0,0 +1,22 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + + + + + + + + + + runtime; build; native; contentfiles; analyzers + compile; contentFiles; build; buildMultitargeting; buildTransitive; analyzers; native + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs new file mode 100644 index 00000000..1dbb06ff --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/IOrderingServiceDbContext.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Data; +using Volo.Abp.EntityFrameworkCore; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore +{ + [ConnectionStringName(OrderingServiceDbProperties.ConnectionStringName)] + public interface IOrderingServiceDbContext : IEfCoreDbContext + { + /* Add DbSet for each Aggregate Root here. Example: + * DbSet Questions { get; } + */ + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs new file mode 100644 index 00000000..d9d01d54 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContext.cs @@ -0,0 +1,35 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp.Data; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore +{ + [ConnectionStringName("Default")] + public class OrderingServiceDbContext : + AbpDbContext + { + public OrderingServiceDbContext(DbContextOptions options) + : base(options) + { + + } + + protected override void OnModelCreating(ModelBuilder builder) + { + base.OnModelCreating(builder); + + /* Include modules to your migration db context */ + + builder.ConfigureOrderingService(); + /* Configure your own tables/entities inside here */ + + //builder.Entity(b => + //{ + // b.ToTable(OrderingServiceConsts.DbTablePrefix + "YourEntities", OrderingServiceConsts.DbSchema); + // b.ConfigureByConvention(); //auto configure for the base class props + // //... + //}); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs new file mode 100644 index 00000000..4ad9d674 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextFactory.cs @@ -0,0 +1,33 @@ +using System.IO; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Design; +using Microsoft.Extensions.Configuration; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore +{ + /* This class is needed for EF Core console commands + * (like Add-Migration and Update-Database commands) */ + public class OrderingServiceDbContextFactory : IDesignTimeDbContextFactory + { + public OrderingServiceDbContext CreateDbContext(string[] args) + { + OrderingServiceEfCoreEntityExtensionMappings.Configure(); + + var configuration = BuildConfiguration(); + + var builder = new DbContextOptionsBuilder() + .UseSqlServer(configuration.GetConnectionString("Default")); + + return new OrderingServiceDbContext(builder.Options); + } + + private static IConfigurationRoot BuildConfiguration() + { + var builder = new ConfigurationBuilder() + .SetBasePath(Path.Combine(Directory.GetCurrentDirectory(), "../EShopOnAbp.OrderingService.HttpApi.Host/")) + .AddJsonFile("appsettings.json", optional: false); + + return builder.Build(); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs new file mode 100644 index 00000000..50e1b749 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceDbContextModelCreatingExtensions.cs @@ -0,0 +1,34 @@ +using Microsoft.EntityFrameworkCore; +using Volo.Abp; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore +{ + public static class OrderingServiceDbContextModelCreatingExtensions + { + public static void ConfigureOrderingService( + this ModelBuilder builder) + { + Check.NotNull(builder, nameof(builder)); + + /* Configure all entities here. Example: + + builder.Entity(b => + { + //Configure table & schema name + b.ToTable(OrderingServiceDbProperties.DbTablePrefix + "Questions", OrderingServiceDbProperties.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/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs new file mode 100644 index 00000000..be594b2e --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEfCoreEntityExtensionMappings.cs @@ -0,0 +1,39 @@ +using Volo.Abp.Threading; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore +{ + public static class OrderingServiceEfCoreEntityExtensionMappings + { + 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 OrderingServiceModuleExtensionConfigurator 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/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs new file mode 100644 index 00000000..008e820c --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreModule.cs @@ -0,0 +1,36 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.EntityFrameworkCore.SqlServer; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore +{ + [DependsOn( + typeof(OrderingServiceDomainModule), + typeof(AbpEntityFrameworkCoreSqlServerModule) + )] + public class OrderingServiceEntityFrameworkCoreModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + OrderingServiceEfCoreEntityExtensionMappings.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 OrderingServiceMigrationsDbContextFactory for EF Core tooling. */ + options.UseSqlServer(); + }); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211012121150_Initial.Designer.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211012121150_Initial.Designer.cs new file mode 100644 index 00000000..6a8184bf --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211012121150_Initial.Designer.cs @@ -0,0 +1,30 @@ +// +using EShopOnAbp.OrderingService.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Migrations; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace EShopOnAbp.OrderingService.Migrations +{ + [DbContext(typeof(OrderingServiceDbContext))] + [Migration("20211012121150_Initial")] + partial class Initial + { + protected override void BuildTargetModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) + .HasAnnotation("ProductVersion", "6.0.0-rc.1.21452.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); +#pragma warning restore 612, 618 + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211012121150_Initial.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211012121150_Initial.cs new file mode 100644 index 00000000..fa11baf7 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/20211012121150_Initial.cs @@ -0,0 +1,19 @@ +using Microsoft.EntityFrameworkCore.Migrations; + +#nullable disable + +namespace EShopOnAbp.OrderingService.Migrations +{ + public partial class Initial : Migration + { + protected override void Up(MigrationBuilder migrationBuilder) + { + + } + + protected override void Down(MigrationBuilder migrationBuilder) + { + + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs new file mode 100644 index 00000000..59bd1666 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Migrations/OrderingServiceDbContextModelSnapshot.cs @@ -0,0 +1,28 @@ +// +using EShopOnAbp.OrderingService.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore; +using Microsoft.EntityFrameworkCore.Infrastructure; +using Microsoft.EntityFrameworkCore.Metadata; +using Microsoft.EntityFrameworkCore.Storage.ValueConversion; +using Volo.Abp.EntityFrameworkCore; + +#nullable disable + +namespace EShopOnAbp.OrderingService.Migrations +{ + [DbContext(typeof(OrderingServiceDbContext))] + partial class OrderingServiceDbContextModelSnapshot : ModelSnapshot + { + protected override void BuildModel(ModelBuilder modelBuilder) + { +#pragma warning disable 612, 618 + modelBuilder + .HasAnnotation("_Abp_DatabaseProvider", EfCoreDatabaseProvider.SqlServer) + .HasAnnotation("ProductVersion", "6.0.0-rc.1.21452.10") + .HasAnnotation("Relational:MaxIdentifierLength", 128); + + SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 1); +#pragma warning restore 612, 618 + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Properties/AssemblyInfo.cs b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..211aa714 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.EntityFrameworkCore/Properties/AssemblyInfo.cs @@ -0,0 +1,2 @@ +using System.Runtime.CompilerServices; +[assembly:InternalsVisibleToAttribute("EShopOnAbp.OrderingService.EntityFrameworkCore.Tests")] diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderingService-generate-proxy.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderingService-generate-proxy.json new file mode 100644 index 00000000..cb296e04 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/OrderingService-generate-proxy.json @@ -0,0 +1,53 @@ +{ + "modules": { + "OrderingService": { + "rootPath": "OrderingService", + "remoteServiceName": "OrderingService", + "controllers": { + "EShopOnAbp.OrderingService.Samples.SampleController": { + "controllerName": "Sample", + "controllerGroupName": "Sample", + "type": "EShopOnAbp.OrderingService.Samples.SampleController", + "interfaces": [ + { + "type": "EShopOnAbp.OrderingService.Samples.ISampleAppService" + } + ], + "actions": { + "GetAsync": { + "uniqueName": "GetAsync", + "name": "GetAsync", + "httpMethod": "GET", + "url": "api/OrderingService/sample", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "EShopOnAbp.OrderingService.Samples.SampleDto", + "typeSimple": "EShopOnAbp.OrderingService.Samples.SampleDto" + }, + "allowAnonymous": null, + "implementFrom": "EShopOnAbp.OrderingService.Samples.ISampleAppService" + }, + "GetAuthorizedAsync": { + "uniqueName": "GetAuthorizedAsync", + "name": "GetAuthorizedAsync", + "httpMethod": "GET", + "url": "api/OrderingService/sample/authorized", + "supportedVersions": [], + "parametersOnMethod": [], + "parameters": [], + "returnValue": { + "type": "EShopOnAbp.OrderingService.Samples.SampleDto", + "typeSimple": "EShopOnAbp.OrderingService.Samples.SampleDto" + }, + "allowAnonymous": false, + "implementFrom": "EShopOnAbp.OrderingService.Samples.ISampleAppService" + } + } + } + } + } + }, + "types": {} +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.Generated.cs new file mode 100644 index 00000000..dd18ffb4 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.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.OrderingService.Samples; + +// ReSharper disable once CheckNamespace +namespace EShopOnAbp.OrderingService.Samples.ClientProxies +{ + +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/ClientProxies/SampleClientProxy.cs new file mode 100644 index 00000000..9cd1a763 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.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.OrderingService.Samples.ClientProxies +{ + public partial class SampleClientProxy + { + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/EShopOnAbp.OrderingService.HttpApi.Client.csproj b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/EShopOnAbp.OrderingService.HttpApi.Client.csproj new file mode 100644 index 00000000..0352b247 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/EShopOnAbp.OrderingService.HttpApi.Client.csproj @@ -0,0 +1,20 @@ + + + + + + netstandard2.0 + EShopOnAbp.OrderingService + + + + + + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs new file mode 100644 index 00000000..1b403c26 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Client/OrderingServiceHttpApiClientModule.cs @@ -0,0 +1,27 @@ +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Http.Client; +using Volo.Abp.Modularity; +using Volo.Abp.VirtualFileSystem; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceApplicationContractsModule), + typeof(AbpHttpClientModule))] + public class OrderingServiceHttpApiClientModule : AbpModule + { + public override void ConfigureServices(ServiceConfigurationContext context) + { + context.Services.AddStaticHttpClientProxies( + typeof(OrderingServiceApplicationContractsModule).Assembly, + OrderingServiceRemoteServiceConsts.RemoteServiceName + ); + + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Controllers/HomeController.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Controllers/HomeController.cs new file mode 100644 index 00000000..c7b2bbe3 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Controllers/HomeController.cs @@ -0,0 +1,13 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; + +namespace EShopOnAbp.OrderingService.Controllers +{ + public class HomeController : AbpController + { + public ActionResult Index() + { + return Redirect("~/swagger"); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs new file mode 100644 index 00000000..3acd7d62 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationChecker.cs @@ -0,0 +1,27 @@ +using EShopOnAbp.OrderingService.EntityFrameworkCore; +using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations; +using System; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; +using Volo.Abp.Uow; + +namespace EShopOnAbp.OrderingService.DbMigrations +{ + public class OrderingServiceDatabaseMigrationChecker : PendingMigrationsCheckerBase + { + public OrderingServiceDatabaseMigrationChecker( + IUnitOfWorkManager unitOfWorkManager, + IServiceProvider serviceProvider, + ICurrentTenant currentTenant, + IDistributedEventBus distributedEventBus) + : base( + unitOfWorkManager, + serviceProvider, + currentTenant, + distributedEventBus, + OrderingServiceDbProperties.ConnectionStringName) + { + + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs new file mode 100644 index 00000000..55649e6e --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/DbMigrations/OrderingServiceDatabaseMigrationEventHandler.cs @@ -0,0 +1,52 @@ +using EShopOnAbp.OrderingService.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.Data; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.MultiTenancy; +using Volo.Abp.TenantManagement; +using Volo.Abp.Uow; + +namespace EShopOnAbp.OrderingService.DbMigrations +{ + public class OrderingServiceDatabaseMigrationEventHandler + : DatabaseMigrationEventHandlerBase, + IDistributedEventHandler + { + public OrderingServiceDatabaseMigrationEventHandler( + 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/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj new file mode 100644 index 00000000..79434b15 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/EShopOnAbp.OrderingService.HttpApi.Host.csproj @@ -0,0 +1,35 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + true + EShopOnAbp.OrderingService-c2d31439-b723-48e2-b061-5ebd7aeb6010 + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs new file mode 100644 index 00000000..f671a9a9 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/OrderingServiceHttpApiHostModule.cs @@ -0,0 +1,94 @@ +using EShopOnAbp.OrderingService.EntityFrameworkCore; +using EShopOnAbp.Shared.Hosting.AspNetCore; +using EShopOnAbp.Shared.Hosting.Microservices; +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Cors; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; +using System; +using System.Collections.Generic; +using System.Linq; +using Volo.Abp; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceHttpApiModule), + typeof(OrderingServiceApplicationModule), + typeof(OrderingServiceEntityFrameworkCoreModule), + typeof(EShopOnAbpSharedHostingMicroservicesModule) + )] + public class OrderingServiceHttpApiHostModule : AbpModule + { + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + JwtBearerConfigurationHelper.Configure(context, "OrderingService"); + // 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 */ + { + {"OrderingService", "Ordering Service API"}, + }, + apiTitle: "Ordering 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(); + }); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Program.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Program.cs new file mode 100644 index 00000000..f5575609 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.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.OrderingService +{ + 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/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Properties/launchSettings.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Properties/launchSettings.json new file mode 100644 index 00000000..157aa953 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Properties/launchSettings.json @@ -0,0 +1,27 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "https://localhost:44380", + "sslPort": 44380 + } + }, + "profiles": { + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "EShopOnAbp.OrderingService.DemoApp": { + "commandName": "Project", + "launchBrowser": true, + "applicationUrl": "https://localhost:44380", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Startup.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Startup.cs new file mode 100644 index 00000000..e962f8b7 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/Startup.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Builder; +using Microsoft.AspNetCore.Hosting; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; + +namespace EShopOnAbp.OrderingService +{ + 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/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json new file mode 100644 index 00000000..493d7662 --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.json @@ -0,0 +1,18 @@ +{ + "App": { + "CorsOrigins": "https://*.OrderingService.com,http://localhost:4200,http://localhost:44307,https://localhost:44307" + }, + "ConnectionStrings": { + "Default": "Server=(LocalDb)\\MSSQLLocalDB;Database=OrderingService_Main;Trusted_Connection=True", + "OrderingService": "Server=(LocalDb)\\MSSQLLocalDB;Database=OrderingService_Module;Trusted_Connection=True" + }, + "Redis": { + "Configuration": "127.0.0.1" + }, + "AuthServer": { + "Authority": "https://localhost:44333/", + "RequireHttpsMetadata": "false", + "SwaggerClientId": "OrderingService_Swagger", + "SwaggerClientSecret": "1q2w3e*" + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.secrets.json b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.secrets.json new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi.Host/appsettings.secrets.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/EShopOnAbp.OrderingService.HttpApi.csproj b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/EShopOnAbp.OrderingService.HttpApi.csproj new file mode 100644 index 00000000..93da1eab --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/EShopOnAbp.OrderingService.HttpApi.csproj @@ -0,0 +1,15 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + + + + + + + + diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs new file mode 100644 index 00000000..2e48136a --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceController.cs @@ -0,0 +1,13 @@ +using EShopOnAbp.OrderingService.Localization; +using Volo.Abp.AspNetCore.Mvc; + +namespace EShopOnAbp.OrderingService +{ + public abstract class OrderingServiceController : AbpControllerBase + { + protected OrderingServiceController() + { + LocalizationResource = typeof(OrderingServiceResource); + } + } +} diff --git a/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs new file mode 100644 index 00000000..d5ac59bc --- /dev/null +++ b/services/ordering/src/EShopOnAbp.OrderingService.HttpApi/OrderingServiceHttpApiModule.cs @@ -0,0 +1,33 @@ +using Localization.Resources.AbpUi; +using EShopOnAbp.OrderingService.Localization; +using Volo.Abp.AspNetCore.Mvc; +using Volo.Abp.Localization; +using Volo.Abp.Modularity; +using Microsoft.Extensions.DependencyInjection; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceApplicationContractsModule), + typeof(AbpAspNetCoreMvcModule))] + public class OrderingServiceHttpApiModule : AbpModule + { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + PreConfigure(mvcBuilder => + { + mvcBuilder.AddApplicationPartIfNotExists(typeof(OrderingServiceHttpApiModule).Assembly); + }); + } + + public override void ConfigureServices(ServiceConfigurationContext context) + { + Configure(options => + { + options.Resources + .Get() + .AddBaseTypes(typeof(AbpUiResource)); + }); + } + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/EShopOnAbp.OrderingService.Application.Tests.csproj b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/EShopOnAbp.OrderingService.Application.Tests.csproj new file mode 100644 index 00000000..f2c9c26e --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/EShopOnAbp.OrderingService.Application.Tests.csproj @@ -0,0 +1,16 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + + + + + + + + + diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/FodyWeavers.xml b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/FodyWeavers.xml new file mode 100644 index 00000000..1715698c --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/FodyWeavers.xsd b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/FodyWeavers.xsd new file mode 100644 index 00000000..ffa6fc4b --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/OrderingServiceApplicationTestBase.cs b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/OrderingServiceApplicationTestBase.cs new file mode 100644 index 00000000..84de9836 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/OrderingServiceApplicationTestBase.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.OrderingService +{ + /* Inherit from this class for your application layer tests. + * See SampleAppService_Tests for example. + */ + public abstract class OrderingServiceApplicationTestBase : OrderingServiceTestBase + { + + } +} \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/OrderingServiceApplicationTestModule.cs b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/OrderingServiceApplicationTestModule.cs new file mode 100644 index 00000000..cad3f898 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Application.Tests/OrderingServiceApplicationTestModule.cs @@ -0,0 +1,13 @@ +using Volo.Abp.Modularity; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceApplicationModule), + typeof(OrderingServiceDomainTestModule) + )] + public class OrderingServiceApplicationTestModule : AbpModule + { + + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/EShopOnAbp.OrderingService.Domain.Tests.csproj b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/EShopOnAbp.OrderingService.Domain.Tests.csproj new file mode 100644 index 00000000..04df4933 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/EShopOnAbp.OrderingService.Domain.Tests.csproj @@ -0,0 +1,15 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + + + + + + + + diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/FodyWeavers.xml b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/FodyWeavers.xml new file mode 100644 index 00000000..1715698c --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/FodyWeavers.xsd b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/FodyWeavers.xsd new file mode 100644 index 00000000..ffa6fc4b --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/OrderingServiceDomainTestBase.cs b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/OrderingServiceDomainTestBase.cs new file mode 100644 index 00000000..b74e2d2d --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/OrderingServiceDomainTestBase.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.OrderingService +{ + /* Inherit from this class for your domain layer tests. + * See SampleManager_Tests for example. + */ + public abstract class OrderingServiceDomainTestBase : OrderingServiceTestBase + { + + } +} \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/OrderingServiceDomainTestModule.cs b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/OrderingServiceDomainTestModule.cs new file mode 100644 index 00000000..cc26f9bf --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/OrderingServiceDomainTestModule.cs @@ -0,0 +1,17 @@ +using EShopOnAbp.OrderingService.EntityFrameworkCore; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.OrderingService +{ + /* 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(OrderingServiceEntityFrameworkCoreTestModule) + )] + public class OrderingServiceDomainTestModule : AbpModule + { + + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/Samples/SampleManager_Tests.cs b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/Samples/SampleManager_Tests.cs new file mode 100644 index 00000000..0f4646ad --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.Domain.Tests/Samples/SampleManager_Tests.cs @@ -0,0 +1,21 @@ +using System.Threading.Tasks; +using Xunit; + +namespace EShopOnAbp.OrderingService.Samples +{ + public class SampleManager_Tests : OrderingServiceDomainTestBase + { + //private readonly SampleManager _sampleManager; + + public SampleManager_Tests() + { + //_sampleManager = GetRequiredService(); + } + + [Fact] + public async Task Method1Async() + { + + } + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests.csproj b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests.csproj new file mode 100644 index 00000000..b49efe8b --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests.csproj @@ -0,0 +1,18 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + + + + + + + + + + + diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreTestBase.cs b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreTestBase.cs new file mode 100644 index 00000000..dcf98e1a --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreTestBase.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.OrderingService.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 OrderingServiceEntityFrameworkCoreTestBase : OrderingServiceTestBase + { + + } +} \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreTestModule.cs b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreTestModule.cs new file mode 100644 index 00000000..318a49be --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/OrderingServiceEntityFrameworkCoreTestModule.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.OrderingService.EntityFrameworkCore +{ + [DependsOn( + typeof(OrderingServiceTestBaseModule), + typeof(OrderingServiceEntityFrameworkCoreModule), + typeof(AbpEntityFrameworkCoreSqliteModule) + )] + public class OrderingServiceEntityFrameworkCoreTestModule : 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 OrderingServiceDbContext( + new DbContextOptionsBuilder().UseSqlite(connection).Options + ).GetService().CreateTables(); + + return connection; + } + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs new file mode 100644 index 00000000..6044bab4 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/EntityFrameworkCore/Samples/SampleRepository_Tests.cs @@ -0,0 +1,12 @@ +using EShopOnAbp.OrderingService.Samples; + +namespace EShopOnAbp.OrderingService.EntityFrameworkCore.Samples +{ + public class SampleRepository_Tests : SampleRepository_Tests + { + /* Don't write custom repository tests here, instead write to + * the base class. + * One exception can be some specific tests related to EF core. + */ + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/FodyWeavers.xml b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/FodyWeavers.xml new file mode 100644 index 00000000..1715698c --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/FodyWeavers.xsd b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/FodyWeavers.xsd new file mode 100644 index 00000000..ffa6fc4b --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.EntityFrameworkCore.Tests/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs new file mode 100644 index 00000000..e57415d3 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ClientDemoService.cs @@ -0,0 +1,147 @@ +using System; +using System.Net.Http; +using System.Threading.Tasks; +using IdentityModel.Client; +using Microsoft.Extensions.Configuration; +using EShopOnAbp.OrderingService.Samples; +using Volo.Abp.DependencyInjection; +using Volo.Abp.IdentityModel; + +namespace EShopOnAbp.OrderingService +{ + 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:OrderingService:BaseUrl"] + + "api/OrderingService/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:OrderingService:BaseUrl"] + + "api/OrderingService/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/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/ConsoleTestAppHostedService.cs new file mode 100644 index 00000000..3a977dfc --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.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.OrderingService.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/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp.csproj b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp.csproj new file mode 100644 index 00000000..884fe289 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp.csproj @@ -0,0 +1,31 @@ + + + + Exe + net6.0 + EShopOnAbp.OrderingService + + + + + + + + + + + PreserveNewest + Always + + + + PreserveNewest + Always + + + + + + + + diff --git a/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/OrderingServiceConsoleApiClientModule.cs b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/OrderingServiceConsoleApiClientModule.cs new file mode 100644 index 00000000..21834043 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/OrderingServiceConsoleApiClientModule.cs @@ -0,0 +1,14 @@ +using Volo.Abp.Http.Client.IdentityModel; +using Volo.Abp.Modularity; + +namespace EShopOnAbp.OrderingService +{ + [DependsOn( + typeof(OrderingServiceHttpApiClientModule), + typeof(AbpHttpClientIdentityModelModule) + )] + public class OrderingServiceConsoleApiClientModule : AbpModule + { + + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/Program.cs b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/Program.cs new file mode 100644 index 00000000..c4283926 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.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.OrderingService.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/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/appsettings.json b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/appsettings.json new file mode 100644 index 00000000..697119ad --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/appsettings.json @@ -0,0 +1,21 @@ +{ + "RemoteServices": { + "Default": { + "BaseUrl": "https://localhost:44333/" + }, + "OrderingService": { + "BaseUrl": "https://localhost:44380/" + } + }, + "IdentityClients": { + "Default": { + "GrantType": "password", + "ClientId": "OrderingService_App", + "ClientSecret": "1q2w3e*", + "UserName": "admin", + "UserPassword": "1q2w3E*", + "Authority": "https://localhost:44333/", + "Scope": "OrderingService" + } + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json new file mode 100644 index 00000000..7a73a41b --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.HttpApi.Client.ConsoleTestApp/appsettings.secrets.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/EShopOnAbp.OrderingService.TestBase.csproj b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/EShopOnAbp.OrderingService.TestBase.csproj new file mode 100644 index 00000000..f0bdf6fb --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/EShopOnAbp.OrderingService.TestBase.csproj @@ -0,0 +1,23 @@ + + + + + + net6.0 + EShopOnAbp.OrderingService + + + + + + + + + + + + + + + + diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/FodyWeavers.xml b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/FodyWeavers.xml new file mode 100644 index 00000000..1715698c --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/FodyWeavers.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/FodyWeavers.xsd b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/FodyWeavers.xsd new file mode 100644 index 00000000..ffa6fc4b --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/FodyWeavers.xsd @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + 'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed. + + + + + A comma-separated list of error codes that can be safely ignored in assembly verification. + + + + + 'false' to turn off automatic generation of the XML Schema file. + + + + + \ No newline at end of file diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceDataSeedContributor.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceDataSeedContributor.cs new file mode 100644 index 00000000..c606e6fa --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceDataSeedContributor.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.OrderingService +{ + public class OrderingServiceDataSeedContributor : IDataSeedContributor, ITransientDependency + { + private readonly IGuidGenerator _guidGenerator; + private readonly ICurrentTenant _currentTenant; + + public OrderingServiceDataSeedContributor( + 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/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestBase.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestBase.cs new file mode 100644 index 00000000..efc2422a --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestBase.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.OrderingService +{ + /* All test classes are derived from this class, directly or indirectly. */ + public abstract class OrderingServiceTestBase : 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/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestBaseModule.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestBaseModule.cs new file mode 100644 index 00000000..3080b0d0 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/OrderingServiceTestBaseModule.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.OrderingService +{ + [DependsOn( + typeof(AbpAutofacModule), + typeof(AbpTestBaseModule), + typeof(AbpAuthorizationModule), + typeof(OrderingServiceDomainModule) + )] + public class OrderingServiceTestBaseModule : 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/ordering/test/EShopOnAbp.OrderingService.TestBase/Samples/SampleRepository_Tests.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/Samples/SampleRepository_Tests.cs new file mode 100644 index 00000000..e3eacf67 --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/Samples/SampleRepository_Tests.cs @@ -0,0 +1,27 @@ +using System.Threading.Tasks; +using Volo.Abp.Modularity; +using Xunit; + +namespace EShopOnAbp.OrderingService.Samples +{ + /* Write your custom repository tests like that, in this project, as abstract classes. + * Then inherit these abstract classes from EF Core & MongoDB test projects. + * In this way, both database providers are tests with the same set tests. + */ + public abstract class SampleRepository_Tests : OrderingServiceTestBase + where TStartupModule : IAbpModule + { + //private readonly ISampleRepository _sampleRepository; + + protected SampleRepository_Tests() + { + //_sampleRepository = GetRequiredService(); + } + + [Fact] + public async Task Method1Async() + { + + } + } +} diff --git a/services/ordering/test/EShopOnAbp.OrderingService.TestBase/Security/FakeCurrentPrincipalAccessor.cs b/services/ordering/test/EShopOnAbp.OrderingService.TestBase/Security/FakeCurrentPrincipalAccessor.cs new file mode 100644 index 00000000..4beab3de --- /dev/null +++ b/services/ordering/test/EShopOnAbp.OrderingService.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.OrderingService.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; + } + } +}