diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs index 367a4080..b1e009f4 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs @@ -1,25 +1,32 @@ using EShopOnAbp.BasketService; using EShopOnAbp.CatalogService; using EShopOnAbp.Localization; +using EShopOnAbp.OrderingService; using EShopOnAbp.PaymentService; +using EShopOnAbp.PaymentService.PaymentMethods; +using EShopOnAbp.PublicWeb.AnonymousUser; +using EShopOnAbp.PublicWeb.Components.Toolbar.Cart; using EShopOnAbp.PublicWeb.Menus; +using EShopOnAbp.PublicWeb.PaymentMethods; using EShopOnAbp.Shared.Hosting.AspNetCore; using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.DataProtection; +using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using Microsoft.IdentityModel.Protocols.OpenIdConnect; using StackExchange.Redis; using System; using System.Net.Http.Headers; -using EShopOnAbp.OrderingService; using Volo.Abp; using Volo.Abp.Account; using Volo.Abp.AspNetCore.Authentication.OpenIdConnect; using Volo.Abp.AspNetCore.Mvc.Client; using Volo.Abp.AspNetCore.Mvc.Localization; +using Volo.Abp.AspNetCore.Mvc.UI.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic; +using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared; using Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared.Toolbars; using Volo.Abp.AspNetCore.SignalR; @@ -27,20 +34,14 @@ using Volo.Abp.AutoMapper; using Volo.Abp.Caching; using Volo.Abp.Caching.StackExchangeRedis; using Volo.Abp.EventBus.RabbitMq; +using Volo.Abp.Http.Client; using Volo.Abp.Http.Client.IdentityModel.Web; using Volo.Abp.Modularity; using Volo.Abp.MultiTenancy; using Volo.Abp.UI.Navigation; using Volo.Abp.UI.Navigation.Urls; -using Yarp.ReverseProxy.Transforms; -using Volo.Abp.AspNetCore.Mvc.UI.Bundling; -using Volo.Abp.AspNetCore.Mvc.UI.Theme.Basic.Bundling; -using EShopOnAbp.PublicWeb.Components.Toolbar.Cart; -using EShopOnAbp.PublicWeb.PaymentMethods; -using EShopOnAbp.PaymentService.PaymentMethods; -using EShopOnAbp.PublicWeb.AnonymousUser; -using Microsoft.Extensions.Configuration; using Volo.Abp.VirtualFileSystem; +using Yarp.ReverseProxy.Transforms; namespace EShopOnAbp.PublicWeb; @@ -77,7 +78,6 @@ public class EShopOnAbpPublicWebModule : AbpModule public override void ConfigureServices(ServiceConfigurationContext context) { Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true; - var hostingEnvironment = context.Services.GetHostingEnvironment(); var configuration = context.Services.GetConfiguration(); ConfigureBasketHttpClient(context); @@ -93,6 +93,12 @@ public class EShopOnAbpPublicWebModule : AbpModule ); }); + context.Services.Configure(options => + { + options.RemoteServices.Default = + new RemoteServiceConfiguration(configuration["RemoteServices:Default:BaseUrl"]); + }); + Configure(options => { options.IsEnabled = true; }); Configure(options => { options.KeyPrefix = "EShopOnAbp:"; }); @@ -167,7 +173,7 @@ public class EShopOnAbpPublicWebModule : AbpModule context.Services.AddStaticHttpClientProxies( typeof(BasketServiceContractsModule).Assembly, remoteServiceConfigurationName: BasketServiceConstants.RemoteServiceName ); - + Configure(options => { options.FileSets.AddEmbedded(); diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml index bbf17a9b..e19737e6 100644 --- a/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml +++ b/apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Index.cshtml @@ -2,8 +2,11 @@ @using EShopOnAbp.Localization @using Microsoft.Extensions.Localization @using System.Globalization +@using Microsoft.Extensions.Options +@using Volo.Abp.Http.Client @model EShopOnAbp.PublicWeb.Pages.IndexModel @inject IStringLocalizer L +@inject IOptions options @{ const int productsColumnSize = 4; // TODO: update abp-column helper to plain html for proper row and columns css @@ -11,12 +14,12 @@ } @section styles{ - + } @section scripts { - - + + } @if (Model.HasRemoteServiceError) @@ -28,7 +31,7 @@

@pageHeader

- @for (int i = 0; i < Math.Ceiling(Model.Products.Count / (double) productsColumnSize); i++) + @for (int i = 0; i < Math.Ceiling(Model.Products.Count / (double)productsColumnSize); i++) { @for (int j = 0; j < productsColumnSize; j++) @@ -38,7 +41,7 @@ { var product = Model.Products[(i * productsColumnSize) + j]; var productPrice = product.Price.ToString("C", new CultureInfo("en-US")); - string productImage = !product.ImageName.IsNullOrEmpty() ? $"/product-images/{product.ImageName}" : "/product-images/@product.ImageName"; + string productImage = !product.ImageName.IsNullOrEmpty() ? $"{options.Value.RemoteServices.Default.BaseUrl}product-images/{product.ImageName}" : $"{options.Value.RemoteServices.Default.BaseUrl}product-images/@product.ImageName"; string buyText = L["Index:AddToBasket"];
@@ -47,10 +50,10 @@ @product.Code - @L["StockCount"]: @product.StockCount
- +
- @if(product.StockCount > 0) - { + @if (product.StockCount > 0) + { } else diff --git a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json index 5c94283d..a436b432 100644 --- a/gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json +++ b/gateways/web-public/src/EShopOnAbp.WebPublicGateway/ocelot.json @@ -52,6 +52,19 @@ "TimeoutValue": 2500 } }, + { + "ServiceKey": "Catalog Service", + "DownstreamPathTemplate": "/product-images/{everything}", + "DownstreamScheme": "https", + "DownstreamHostAndPorts": [ + { + "Host": "localhost", + "Port": 44354 + } + ], + "UpstreamPathTemplate": "/product-images/{everything}", + "UpstreamHttpMethod": [ "Get" ] + }, { "ServiceKey": "Basket Service", "DownstreamPathTemplate": "/api/basket/{everything}", diff --git a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs index 97bef87e..5f84825a 100644 --- a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs +++ b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs @@ -28,18 +28,18 @@ namespace EShopOnAbp.BasketService; typeof(BasketServiceContractsModule), typeof(EShopOnAbpSharedHostingMicroservicesModule) )] -public class BasketServiceModule : AbpModule +public class BasketServiceModule : AbpModule { public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = hostingEnvironment.IsDevelopment(); - + var configuration = context.Services.GetConfiguration(); ConfigureAutoMapper(); - ConfigureAspNetCoreRouting(context); + ConfigureAspNetCoreRouting(); ConfigureGrpc(context); ConfigureDistributedCache(); ConfigureVirtualFileSystem(); @@ -48,7 +48,7 @@ public class BasketServiceModule : AbpModule ConfigureAutoApiControllers(); } - private void ConfigureAspNetCoreRouting(ServiceConfigurationContext context) + private void ConfigureAspNetCoreRouting() { Configure(options => { @@ -91,7 +91,7 @@ public class BasketServiceModule : AbpModule app.UseUnitOfWork(); app.UseConfiguredEndpoints(); } - + private void ConfigureSwagger(ServiceConfigurationContext context, IConfiguration configuration) { SwaggerConfigurationHelper.ConfigureWithAuth( @@ -105,7 +105,7 @@ public class BasketServiceModule : AbpModule apiTitle: "Basket Service API" ); } - + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) { JwtBearerConfigurationHelper.Configure(context, "BasketService"); @@ -128,7 +128,7 @@ public class BasketServiceModule : AbpModule .AllowCredentials(); }); }); - + Configure(options => { options.AutoValidate = false; }); } @@ -142,12 +142,12 @@ public class BasketServiceModule : AbpModule private void ConfigureGrpc(ServiceConfigurationContext context) { - context.Services.AddGrpcClient((services, options) => + context.Services.AddGrpcClient((services, options) => { var remoteServiceOptions = services.GetRequiredService>().CurrentValue; var catalogServiceConfiguration = remoteServiceOptions.RemoteServices.GetConfigurationOrDefault("Catalog"); var catalogGrpcUrl = catalogServiceConfiguration.GetOrDefault("GrpcUrl"); - + options.Address = new Uri(catalogGrpcUrl); }); } diff --git a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj index 6a0af54a..b7bab860 100644 --- a/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj +++ b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/EShopOnAbp.CatalogService.HttpApi.Host.csproj @@ -1,4 +1,4 @@ - + @@ -30,4 +30,14 @@ + + + + + + + PreserveNewest + + + diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/asus.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/asus.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/asus.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/asus.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/beats.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/beats.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/beats.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/beats.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/bluecat.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/bluecat.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/bluecat.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/bluecat.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/lego.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/lego.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/lego.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/lego.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/nikon.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/nikon.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/nikon.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/nikon.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/noimage.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/noimage.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/noimage.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/noimage.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/oki.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/oki.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/oki.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/oki.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/playstation.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/playstation.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/playstation.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/playstation.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/rampage.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/rampage.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/rampage.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/rampage.jpg diff --git a/apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/sunny.jpg b/services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/sunny.jpg similarity index 100% rename from apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/sunny.jpg rename to services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/wwwroot/product-images/sunny.jpg