diff --git a/services/basket/EShopOnAbp.BasketService.sln b/services/basket/EShopOnAbp.BasketService.sln index 7af39ec3..48f58826 100644 --- a/services/basket/EShopOnAbp.BasketService.sln +++ b/services/basket/EShopOnAbp.BasketService.sln @@ -31,6 +31,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.BasketService.Ht EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EShopOnAbp.BasketService.HttpApi.Host", "src\EShopOnAbp.BasketService.HttpApi.Host\EShopOnAbp.BasketService.HttpApi.Host.csproj", "{748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EShopOnAbp.BasketService", "src\EShopOnAbp.BasketService\EShopOnAbp.BasketService.csproj", "{83F0BE02-6B71-4695-B86F-18DEEE34B485}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -85,6 +87,10 @@ Global {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Debug|Any CPU.Build.0 = Debug|Any CPU {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.ActiveCfg = Release|Any CPU {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D}.Release|Any CPU.Build.0 = Release|Any CPU + {83F0BE02-6B71-4695-B86F-18DEEE34B485}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {83F0BE02-6B71-4695-B86F-18DEEE34B485}.Debug|Any CPU.Build.0 = Debug|Any CPU + {83F0BE02-6B71-4695-B86F-18DEEE34B485}.Release|Any CPU.ActiveCfg = Release|Any CPU + {83F0BE02-6B71-4695-B86F-18DEEE34B485}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -102,6 +108,7 @@ Global {E512F4D9-9375-480F-A2F6-A46509F9D824} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {EF480016-9127-4916-8735-D2466BDBC582} = {04DBDB01-70F4-4E06-B468-8F87850B22BE} {748584B1-BA69-4F6A-81AA-F4BDE6BCE29D} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} + {83F0BE02-6B71-4695-B86F-18DEEE34B485} = {CA9AC87F-097E-4F15-8393-4BC07735A5B0} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {6AAFA1C6-603E-13FA-45E5-7910AA9F661D} diff --git a/services/basket/src/EShopOnAbp.BasketService/BasketServiceAutoMapperProfile.cs b/services/basket/src/EShopOnAbp.BasketService/BasketServiceAutoMapperProfile.cs new file mode 100644 index 00000000..b276ab1c --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/BasketServiceAutoMapperProfile.cs @@ -0,0 +1,14 @@ +using AutoMapper; +using EShopOnAbp.CatalogService.Grpc; +using EShopOnAbp.CatalogService.Products; + +namespace EShopOnAbp.BasketService; + +public class BasketServiceApplicationAutoMapperProfile : Profile +{ + public BasketServiceApplicationAutoMapperProfile() + { + CreateMap(); + CreateMap(); + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs new file mode 100644 index 00000000..5d1b9984 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/BasketServiceModule.cs @@ -0,0 +1,184 @@ +using EShopOnAbp.BasketService.Entities; +using EShopOnAbp.BasketService.Localization; +using EShopOnAbp.CatalogService.Grpc; +using EShopOnAbp.Shared.Hosting.AspNetCore; +using EShopOnAbp.Shared.Hosting.Microservices; +using Microsoft.AspNetCore.Cors; +using Microsoft.Extensions.Caching.Distributed; +using Microsoft.Extensions.Options; +using Volo.Abp; +using Volo.Abp.AspNetCore.Mvc.AntiForgery; +using Volo.Abp.AutoMapper; +using Volo.Abp.Caching; +using Volo.Abp.Http.Client; +using Volo.Abp.Localization; +using Volo.Abp.Localization.ExceptionHandling; +using Volo.Abp.Modularity; +using Volo.Abp.Validation.Localization; +using Volo.Abp.VirtualFileSystem; + +namespace EShopOnAbp.BasketService +{ + [DependsOn( + )] + public class BasketServiceModule : AbpModule + { + public const string RemoteServiceName = "Basket"; + + public override void ConfigureServices(ServiceConfigurationContext context) + { + var hostingEnvironment = context.Services.GetHostingEnvironment(); + var configuration = context.Services.GetConfiguration(); + + ConfigureAutoMapper(); + ConfigureGrpc(context); + ConfigureDistributedCache(); + ConfigureVirtualFileSystem(); + ConfigureLocalization(); + ConfigureHttpApiProxy(context); + ConfigureAuthentication(context, configuration); + } + + 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.UseAuthentication(); + app.UseAbpClaimsMap(); + app.UseAuthorization(); + app.UseSwagger(); + app.UseSwaggerUI(options => + { + var configuration = context.ServiceProvider.GetRequiredService(); + options.SwaggerEndpoint("/swagger/v1/swagger.json", "Basket Service API"); + options.OAuthClientId(configuration["AuthServer:SwaggerClientId"]); + options.OAuthClientSecret(configuration["AuthServer:SwaggerClientSecret"]); + }); + app.UseAbpSerilogEnrichers(); + app.UseAuditing(); + app.UseUnitOfWork(); + app.UseConfiguredEndpoints(); + } + + private void ConfigureAuthentication(ServiceConfigurationContext context, IConfiguration configuration) + { + JwtBearerConfigurationHelper.Configure(context, "BasketService"); + + SwaggerWithAuthConfigurationHelper.Configure( + context: context, + authority: configuration["AuthServer:Authority"], + scopes: new + Dictionary /* Requested scopes for authorization code request and descriptions for swagger UI only */ + { + {"BasketService", "Basket Service API"} + }, + apiTitle: "Basket 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(); + }); + }); + + Configure(options => { options.AutoValidate = false; }); + } + + private void ConfigureHttpApiProxy(ServiceConfigurationContext context) + { + context.Services.AddStaticHttpClientProxies( + typeof(BasketServiceApplicationContractsModule).Assembly, + RemoteServiceName + ); + } + + private void ConfigureGrpc(ServiceConfigurationContext context) + { + 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); + }); + } + + private void ConfigureAutoMapper() + { + Configure(options => + { + options.AddMaps(); + }); + } + + private void ConfigureDistributedCache() + { + Configure(options => + { + options.CacheConfigurators.Add(cacheName => + { + if (cacheName == CacheNameAttribute.GetCacheName(typeof(Basket))) + { + return new DistributedCacheEntryOptions + { + SlidingExpiration = TimeSpan.FromDays(7) + }; + } + + return null; + }); + }); + } + + private void ConfigureVirtualFileSystem() + { + Configure(options => + { + options.FileSets.AddEmbedded(); + }); + } + + private void ConfigureLocalization() + { + Configure(options => + { + options.Resources + .Add("en") + .AddBaseTypes(typeof(AbpValidationResource)) + .AddVirtualJson("/Localization/BasketService"); + + options.DefaultResourceType = typeof(BasketServiceResource); + }); + + Configure(options => + { + options.MapCodeNamespace("BasketService", typeof(BasketServiceResource)); + }); + } + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Controllers/HomeController.cs b/services/basket/src/EShopOnAbp.BasketService/Controllers/HomeController.cs new file mode 100644 index 00000000..3ff3cceb --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Controllers/HomeController.cs @@ -0,0 +1,12 @@ +using Microsoft.AspNetCore.Mvc; +using Volo.Abp.AspNetCore.Mvc; + +namespace EShopOnAbp.BasketService.Controllers; + +public class HomeController : AbpController +{ + public ActionResult Index() + { + return Redirect("~/swagger"); + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj b/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj new file mode 100644 index 00000000..23c87340 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/EShopOnAbp.BasketService.csproj @@ -0,0 +1,67 @@ + + + + net6.0 + enable + enable + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/Basket.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/Basket.cs new file mode 100644 index 00000000..efdf7e5d --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/Basket.cs @@ -0,0 +1,77 @@ +using Volo.Abp.Domain.Entities; + +namespace EShopOnAbp.BasketService.Entities; + +public class Basket : AggregateRoot +{ + public List Items { get; set; } + + private Basket() + { + } + + public Basket(Guid id) + : base(id) + { + Items = new List(); + } + + public void AddProduct(Guid productId, int count = 1) + { + if (count < 1) + { + throw new ArgumentOutOfRangeException(nameof(count), "Product count should be 1 or more!"); + } + + var item = Items.FirstOrDefault(x => x.ProductId == productId); + if (item == null) + { + Items.Add(new BasketItem(productId, count)); + } + else + { + item.Count += count; + } + } + + public void RemoveProduct(Guid productId, int? count = null) + { + if (count is < 1) + { + throw new ArgumentOutOfRangeException(nameof(count), "Product count should be null, 1 or more!"); + } + + var item = Items.FirstOrDefault(x => x.ProductId == productId); + if (item == null) + { + return; + } + + if (count == null || item.Count <= count) + { + Items.Remove(item); + return; + } + + item.Count -= count.Value; + } + + public int GetProductCount(Guid productId) + { + var item = Items.FirstOrDefault(x => x.ProductId == productId); + return item?.Count ?? 0; + } + + public void Clear() + { + Items.Clear(); + } + + public void Merge(Basket basket) + { + foreach (var item in basket.Items) + { + AddProduct(item.ProductId, item.Count); + } + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/BasketItem.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/BasketItem.cs new file mode 100644 index 00000000..49576247 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/BasketItem.cs @@ -0,0 +1,18 @@ +namespace EShopOnAbp.BasketService.Entities; + +public class BasketItem +{ + public Guid ProductId { get; private set; } + public int Count { get; internal set; } + + private BasketItem() + { + + } + + public BasketItem(Guid productId, int count = 1) + { + ProductId = productId; + Count = count; + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/BasketProductUpdatedEto.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/BasketProductUpdatedEto.cs new file mode 100644 index 00000000..aa4f3cfc --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/BasketProductUpdatedEto.cs @@ -0,0 +1,7 @@ +namespace EShopOnAbp.BasketService.Entities; + +public class BasketProductUpdatedEto +{ + public Guid ProductId { get; set; } + public string ProductName { get; set; } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/BasketRepository.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/BasketRepository.cs new file mode 100644 index 00000000..b1d796ce --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/BasketRepository.cs @@ -0,0 +1,23 @@ +using Volo.Abp.Caching; + +namespace EShopOnAbp.BasketService.Entities; + +public class BasketRepository : IBasketRepository +{ + private readonly IDistributedCache _cache; + + public BasketRepository(IDistributedCache cache) + { + _cache = cache; + } + + public async Task GetAsync(Guid id) + { + return await _cache.GetOrAddAsync(id, () => Task.FromResult(new Basket(id))); + } + + public async Task UpdateAsync(Basket basket) + { + await _cache.SetAsync(basket.Id, basket); + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/IBasketRepository.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/IBasketRepository.cs new file mode 100644 index 00000000..bd6dbadb --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/IBasketRepository.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Domain.Repositories; + +namespace EShopOnAbp.BasketService.Entities; + +public interface IBasketRepository : IRepository +{ + Task GetAsync(Guid id); + + Task UpdateAsync(Basket basket); +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs b/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs new file mode 100644 index 00000000..0716d8fd --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Entities/Orders/OrderPlacedEventHandler.cs @@ -0,0 +1,25 @@ +using EShopOnAbp.OrderingService.Orders; +using Volo.Abp.DependencyInjection; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.Uow; + +namespace EShopOnAbp.BasketService.Entities.Orders +{ + public class OrderPlacedEventHandler : IDistributedEventHandler, ITransientDependency + { + private readonly IBasketRepository _basketRepository; + + public OrderPlacedEventHandler(IBasketRepository basketRepository) + { + _basketRepository = basketRepository; + } + + [UnitOfWork] + public async Task HandleEventAsync(OrderPlacedEto eventData) + { + var basket = await _basketRepository.GetAsync(eventData.Buyer.BuyerId.GetValueOrDefault()); + basket.Clear(); + await _basketRepository.UpdateAsync(basket); + } + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ar.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ar.json new file mode 100644 index 00000000..3e5227a9 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ar.json @@ -0,0 +1,8 @@ +{ + "culture": "ar", + "texts": { + "Menu:Home": "الرئيسية", + "Welcome": "مرحبا", + "LongWelcomeMessage": "مرحبا بكم في التطبيق. هذا مشروع بدء تشغيل يعتمد على إطار عمل ABP. لمزيد من المعلومات ، يرجى زيارة abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/cs.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/cs.json new file mode 100644 index 00000000..5a0bbf61 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/cs.json @@ -0,0 +1,8 @@ +{ + "culture": "cs", + "texts": { + "Menu:Home": "Úvod", + "Welcome": "Vítejte", + "LongWelcomeMessage": "Vítejte v aplikaci. Toto je startovací projekt založený na ABP frameworku. Pro více informací, navštivte abp.io." + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/de-DE.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/de-DE.json new file mode 100644 index 00000000..aca4528c --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/de-DE.json @@ -0,0 +1,8 @@ +{ + "culture": "de-DE", + "texts": { + "Menu:Home": "Home", + "Welcome": "Willkommen", + "LongWelcomeMessage": "Willkommen bei der Anwendung. Dies ist ein Startup-Projekt, das auf dem ABP-Framework basiert. Weitere Informationen finden Sie unter abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/en-GB.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/en-GB.json new file mode 100644 index 00000000..d2ca0793 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/en-GB.json @@ -0,0 +1,8 @@ +{ + "culture": "en-GB", + "texts": { + "Menu:Home": "Home", + "Welcome": "Welcome", + "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/en.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/en.json new file mode 100644 index 00000000..f44c9b4a --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/en.json @@ -0,0 +1,12 @@ +{ + "culture": "en", + "texts": { + "Menu:Home": "Home", + "Welcome": "Welcome", + "LongWelcomeMessage": "Welcome to the application. This is a startup project based on the ABP framework. For more information, visit abp.io.", + "Toolbar:Cart": "My Cart", + "Toolbar:BasketNotLoaded": "Couldn't Load!", + "Toolbar:CartEmpty": "Cart is Empty!", + "ProductNotFound": "Could not find the product!" + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/es.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/es.json new file mode 100644 index 00000000..31b4b59e --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/es.json @@ -0,0 +1,8 @@ +{ + "culture": "es", + "texts": { + "Menu:Home": "Inicio", + "Welcome": "Bienvenido", + "LongWelcomeMessage": "Bienvenido a la aplicación, este es un proyecto base basado en el framework ABP. Para más información, visita abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/fi.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/fi.json new file mode 100644 index 00000000..a318859f --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/fi.json @@ -0,0 +1,8 @@ +{ + "culture": "fi", + "texts": { + "Menu:Home": "Koti", + "Welcome": "Tervetuloa", + "LongWelcomeMessage": "Tervetuloa sovellukseen. Tämä on ABP-kehykseen perustuva käynnistysprojekti. Lisätietoja on osoitteessa abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/fr.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/fr.json new file mode 100644 index 00000000..e76eac0c --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/fr.json @@ -0,0 +1,8 @@ +{ + "culture": "fr", + "texts": { + "Menu:Home": "Accueil", + "Welcome": "Bienvenue", + "LongWelcomeMessage": "Bienvenue dans l'application. Il s'agit d'un projet de démarrage basé sur le framework ABP. Pour plus d'informations, visitez abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/hi.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/hi.json new file mode 100644 index 00000000..a1676bfd --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/hi.json @@ -0,0 +1,8 @@ +{ + "culture": "hi", + "texts": { + "Menu:Home": "घर", + "Welcome": "स्वागत हे", + "LongWelcomeMessage": "आवेदन करने के लिए आपका स्वागत है। यह एबीपी ढांचे पर आधारित एक स्टार्टअप परियोजना है। अधिक जानकारी के लिए, abp.io पर जाएं।" + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/hu.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/hu.json new file mode 100644 index 00000000..c7b6a33a --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/hu.json @@ -0,0 +1,8 @@ +{ + "culture": "hu", + "texts": { + "Menu:Home": "Kezdőlap", + "Welcome": "Üdvözlöm", + "LongWelcomeMessage": "Üdvözöljük az alkalmazásban. Ez egy ABP keretrendszeren alapuló startup projekt. További információkért látogasson el az abp.io oldalra." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/it.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/it.json new file mode 100644 index 00000000..82ce42b0 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/it.json @@ -0,0 +1,8 @@ +{ + "culture": "it", + "texts": { + "Menu:Home": "Home", + "Welcome": "Benvenuto", + "LongWelcomeMessage": "Benvenuto nell'applicazione. Questo è un progetto di avvio basato sul framework ABP. Per ulteriori informazioni, visita abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/nl.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/nl.json new file mode 100644 index 00000000..9ba8da47 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/nl.json @@ -0,0 +1,8 @@ +{ + "culture": "nl", + "texts": { + "Menu:Home": "Home", + "Welcome": "Welkom", + "LongWelcomeMessage": "Welkom bij de applicatie. Dit is een startup-project gebaseerd op het ABP-framework. Bezoek abp.io voor meer informatie." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/pl-PL.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/pl-PL.json new file mode 100644 index 00000000..33412f30 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/pl-PL.json @@ -0,0 +1,8 @@ +{ + "culture": "pl-PL", + "texts": { + "Menu:Home": "Home", + "Welcome": "Witaj", + "LongWelcomeMessage": "Witaj w aplikacji. To jest inicjalny projekt bazujący na ABP framework. Po więcej informacji odwiedź stronę abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/pt-BR.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/pt-BR.json new file mode 100644 index 00000000..8c818a07 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/pt-BR.json @@ -0,0 +1,8 @@ +{ + "culture": "pt-BR", + "texts": { + "Menu:Home": "Principal", + "Welcome": "Seja bem-vindo!", + "LongWelcomeMessage": "Bem-vindo a esta aplicação. Este é um projeto inicial baseado no ABP framework. Para mais informações, visite abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ro-RO.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ro-RO.json new file mode 100644 index 00000000..1fe56019 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ro-RO.json @@ -0,0 +1,8 @@ +{ + "culture": "ro-RO", + "texts": { + "Menu:Home": "Acasă", + "Welcome": "Bun venit", + "LongWelcomeMessage": "Bun venit la aplicaţie. Acesta este un proiect de pornire bazat pe framework-ul ABP. Pentru mai multe informaţii, vizitaţi, visit abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ru.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ru.json new file mode 100644 index 00000000..8464e443 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/ru.json @@ -0,0 +1,8 @@ +{ + "culture": "ru", + "texts": { + "Menu:Home": "Главная", + "Welcome": "Добро пожаловать", + "LongWelcomeMessage": "Добро пожаловать в приложение. Этот запущенный проект основан на фреймворке ABP. Для получения дополнительной информации посетите сайт abp.io." + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/sk.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/sk.json new file mode 100644 index 00000000..4f35aaf1 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/sk.json @@ -0,0 +1,8 @@ +{ + "culture": "sk", + "texts": { + "Menu:Home": "Domov", + "Welcome": "Vitajte", + "LongWelcomeMessage": "Vitajte v aplikácii. Toto je štartovací projekt založený na ABP frameworku. Viac informácií nájdete na stránke abp.io." + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/sl.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/sl.json new file mode 100644 index 00000000..a066ef26 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/sl.json @@ -0,0 +1,8 @@ +{ + "culture": "sl", + "texts": { + "Menu:Home": "Domov", + "Welcome": "Dobrodošli", + "LongWelcomeMessage": "Dobrodošli v aplikaciji. To je začetni projekt na osnovi okolja ABP. Za več informacij obiščite abp.io." + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/tr.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/tr.json new file mode 100644 index 00000000..fc0fef09 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/tr.json @@ -0,0 +1,12 @@ +{ + "culture": "tr", + "texts": { + "Menu:Home": "Ana sayfa", + "Welcome": "Hoşgeldiniz", + "LongWelcomeMessage": "Uygulamaya hoşgeldiniz. Bu, ABP framework'ü üzerine bina edilmiş bir başlangıç projesidir. Daha fazla bilgi için abp.io adresini ziyaret edebilirsiniz.", + "Toolbar:Cart": "Sepetim", + "Toolbar:BasketNotLoaded": "Sepet Hatası!", + "Toolbar:CartEmpty": "Sepetiniz Boş", + "ProductNotFound": "Bu ürün bulunamadı!" + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/vi.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/vi.json new file mode 100644 index 00000000..c115a357 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/vi.json @@ -0,0 +1,8 @@ +{ + "culture": "vi", + "texts": { + "Menu:Home": "Trang chủ", + "Welcome": "Chào mừng bạn", + "LongWelcomeMessage": "Chào mừng bạn đến ứng dụng. Đây là một dự án khởi nghiệp dựa trên khung ABP. Để biết thêm thông tin, hãy truy cập abp.io." + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/zh-Hans.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/zh-Hans.json new file mode 100644 index 00000000..3c0ebef5 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/zh-Hans.json @@ -0,0 +1,10 @@ +{ + "culture": "zh-Hans", + "texts": { + "Menu:Home": "首页", + "Welcome": "欢迎", + "LongWelcomeMessage": "欢迎来到该应用程序. 这是一个基于ABP框架的启动项目. 有关更多信息, 请访问 abp.io.", + "Toolbar:Cart": "我的购物车", + "Toolbar:BasketNotLoaded": "无法加载!" + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/zh-Hant.json b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/zh-Hant.json new file mode 100644 index 00000000..31e0ab5a --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketService/zh-Hant.json @@ -0,0 +1,8 @@ +{ + "culture": "zh-Hant", + "texts": { + "Menu:Home": "首頁", + "Welcome": "歡迎", + "LongWelcomeMessage": "歡迎來到此應用程式. 這是一個基於ABP框架的起始專案. 有關更多訊息, 請瀏覽 abp.io." + } + } \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Localization/BasketServiceResource.cs b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketServiceResource.cs new file mode 100644 index 00000000..07aca7a0 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Localization/BasketServiceResource.cs @@ -0,0 +1,10 @@ +using Volo.Abp.Localization; + +namespace EShopOnAbp.BasketService.Localization +{ + [LocalizationResourceName("BasketService")] + public class BasketServiceResource + { + + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Program.cs b/services/basket/src/EShopOnAbp.BasketService/Program.cs new file mode 100644 index 00000000..ec8e4f41 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Program.cs @@ -0,0 +1,6 @@ +var builder = WebApplication.CreateBuilder(args); +var app = builder.Build(); + +app.MapGet("/", () => "Hello World!"); + +app.Run(); \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Properties/launchSettings.json b/services/basket/src/EShopOnAbp.BasketService/Properties/launchSettings.json new file mode 100644 index 00000000..75ea0aca --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Properties/launchSettings.json @@ -0,0 +1,28 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:43756", + "sslPort": 44365 + } + }, + "profiles": { + "EShopOnAbp.BasketService": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7198;http://localhost:5198", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/BasketAppService.cs b/services/basket/src/EShopOnAbp.BasketService/Services/BasketAppService.cs new file mode 100644 index 00000000..7cbe07d8 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/BasketAppService.cs @@ -0,0 +1,124 @@ +using EShopOnAbp.BasketService.Entities; +using EShopOnAbp.BasketService.Localization; +using EShopOnAbp.BasketService.Services.Dtos; +using EShopOnAbp.CatalogService.Products; +using Volo.Abp; +using Volo.Abp.Application.Services; +using Volo.Abp.Users; + +namespace EShopOnAbp.BasketService.Services; + +public class BasketAppService : ApplicationService, IBasketAppService +{ + private readonly IBasketRepository _basketRepository; + private readonly IBasketProductService _basketProductService; + + public BasketAppService( + IBasketRepository basketRepository, + IBasketProductService basketProductService) + { + _basketRepository = basketRepository; + _basketProductService = basketProductService; + LocalizationResource = typeof(BasketServiceResource); + } + + public async Task GetAsync(Guid? anonymousUserId) + { + if (anonymousUserId != null && CurrentUser.IsAuthenticated) + { + var userBasket = await _basketRepository.GetAsync(CurrentUser.GetId()); + var anonymousUserBasket = await _basketRepository.GetAsync(anonymousUserId.Value); + + userBasket.Merge(anonymousUserBasket); + await _basketRepository.UpdateAsync(userBasket); + + anonymousUserBasket.Clear(); + await _basketRepository.UpdateAsync(anonymousUserBasket); + + return await GetBasketDtoAsync(userBasket); + } + + if (anonymousUserId != null && !CurrentUser.IsAuthenticated) + { + return await GetBasketDtoAsync(await _basketRepository.GetAsync(anonymousUserId.Value)); + } + + return await GetBasketDtoAsync(await _basketRepository.GetAsync(CurrentUser.GetId())); + } + + public async Task AddProductAsync(AddProductDto input) + { + Guid userId = CurrentUser.IsAuthenticated ? CurrentUser.GetId() : input.AnonymousId.GetValueOrDefault(); + + var basket = await _basketRepository.GetAsync(userId); + var product = await _basketProductService.GetAsync(input.ProductId); + + if (basket.GetProductCount(product.Id) >= product.StockCount) + { + throw new UserFriendlyException("There is not enough product in stock, sorry :("); + } + + basket.AddProduct(product.Id); + + await _basketRepository.UpdateAsync(basket); + + return await GetBasketDtoAsync(basket); + } + + public async Task RemoveProductAsync(RemoveProductDto input) + { + Guid userId = CurrentUser.IsAuthenticated ? CurrentUser.GetId() : input.AnonymousId.GetValueOrDefault(); + + var basket = await _basketRepository.GetAsync(userId); + var product = await _basketProductService.GetAsync(input.ProductId); + + basket.RemoveProduct(product.Id, input.Count); + + await _basketRepository.UpdateAsync(basket); + + return await GetBasketDtoAsync(basket); + } + + private async Task GetBasketDtoAsync(Basket basket) + { + var products = new Dictionary(); + var basketDto = new BasketDto(); + var basketChanged = false; + + foreach (var basketItem in basket.Items) + { + var productDto = products.GetOrDefault(basketItem.ProductId); + if (productDto == null) + { + productDto = await _basketProductService.GetAsync(basketItem.ProductId); + products[productDto.Id] = productDto; + } + + //Removing the products if not available in the stock + if (basketItem.Count > productDto.StockCount) + { + basket.RemoveProduct(basketItem.ProductId, basketItem.Count - productDto.StockCount); + basketChanged = true; + } + + basketDto.Items.Add(new BasketItemDto + { + ProductId = basketItem.ProductId, + Count = basketItem.Count, + ProductCode = productDto.Code, + ImageName = productDto.ImageName, + ProductName = productDto.Name, + TotalPrice = productDto.Price * basketItem.Count + }); + } + + basketDto.TotalPrice = basketDto.Items.Sum(x => x.TotalPrice); + + if (basketChanged) + { + await _basketRepository.UpdateAsync(basket); + } + + return basketDto; + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/BasketProductEventHandler.cs b/services/basket/src/EShopOnAbp.BasketService/Services/BasketProductEventHandler.cs new file mode 100644 index 00000000..ced0798d --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/BasketProductEventHandler.cs @@ -0,0 +1,46 @@ +using EShopOnAbp.BasketService.Entities; +using EShopOnAbp.CatalogService.Products; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Domain.Entities.Events.Distributed; +using Volo.Abp.EventBus.Distributed; +using Volo.Abp.ObjectMapping; + +namespace EShopOnAbp.BasketService.Services; + +public class BasketProductEventHandler : IDistributedEventHandler>, ITransientDependency +{ + private readonly IDistributedCache _cache; + private readonly IObjectMapper _objectMapper; + private readonly IDistributedEventBus _distributedEventBus; + + public BasketProductEventHandler( + IDistributedCache cache, + IObjectMapper objectMapper, + IDistributedEventBus distributedEventBus) + { + _cache = cache; + _objectMapper = objectMapper; + _distributedEventBus = distributedEventBus; + } + + public async Task HandleEventAsync(EntityUpdatedEto eventData) + { + var cachedProductDto = await _cache.GetAsync(eventData.Entity.Id); + if (cachedProductDto == null) + { + return; + } + + _objectMapper.Map(eventData.Entity, cachedProductDto); + + await _cache.SetAsync(eventData.Entity.Id, cachedProductDto); + + await _distributedEventBus.PublishAsync( + new BasketProductUpdatedEto + { + ProductId = eventData.Entity.Id, + ProductName = eventData.Entity.Name + }); + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/BasketProductService.cs b/services/basket/src/EShopOnAbp.BasketService/Services/BasketProductService.cs new file mode 100644 index 00000000..b3a19472 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/BasketProductService.cs @@ -0,0 +1,46 @@ +using EShopOnAbp.CatalogService.Grpc; +using EShopOnAbp.CatalogService.Products; +using Volo.Abp; +using Volo.Abp.Caching; +using Volo.Abp.DependencyInjection; +using Volo.Abp.ObjectMapping; + +namespace EShopOnAbp.BasketService.Services; + +public class BasketProductService : IBasketProductService, ITransientDependency +{ + private readonly IDistributedCache _cache; + private readonly ILogger _logger; + private readonly IObjectMapper _mapper; + private readonly ProductPublic.ProductPublicClient _productPublicGrpcClient; + + public BasketProductService( + IDistributedCache cache, + ILogger logger, + IObjectMapper mapper, + ProductPublic.ProductPublicClient productPublicGrpcClient) + { + _cache = cache; + _logger = logger; + _mapper = mapper; + _productPublicGrpcClient = productPublicGrpcClient; + } + + public async Task GetAsync(Guid productId) + { + return await _cache.GetOrAddAsync( + productId, + () => GetProductAsync(productId) + ); + } + + private async Task GetProductAsync(Guid productId) + { + var request = new ProductRequest { Id = productId.ToString() }; + _logger.LogInformation("=== GRPC request {@request}", request); + var response = await _productPublicGrpcClient.GetByIdAsync(request); + _logger.LogInformation("=== GRPC response {@response}", response); + return _mapper.Map(response) ?? + throw new UserFriendlyException(BasketServiceDomainErrorCodes.ProductNotFound); + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/AddProductDto.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/AddProductDto.cs new file mode 100644 index 00000000..9a9db3ce --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/AddProductDto.cs @@ -0,0 +1,13 @@ +using System.ComponentModel.DataAnnotations; + +namespace EShopOnAbp.BasketService.Services.Dtos; + +public class AddProductDto : IHasAnonymousId +{ + public Guid ProductId { get; set; } + + [Range(1, int.MaxValue)] + public int Count { get; set; } = 1; + + public Guid? AnonymousId { get; set; } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/BasketDto.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/BasketDto.cs new file mode 100644 index 00000000..16208787 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/BasketDto.cs @@ -0,0 +1,12 @@ +namespace EShopOnAbp.BasketService.Services.Dtos; + +public class BasketDto +{ + public float TotalPrice { get; set; } + public List Items { get; set; } + + public BasketDto() + { + Items = new List(); + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/BasketItemDto.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/BasketItemDto.cs new file mode 100644 index 00000000..44a03a40 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/BasketItemDto.cs @@ -0,0 +1,11 @@ +namespace EShopOnAbp.BasketService.Services.Dtos; + +public class BasketItemDto +{ + public Guid ProductId { get; set; } + public string ProductName { get; set; } + public string ProductCode { get; set; } + public string ImageName { get; set; } + public int Count { get; set; } + public float TotalPrice { get; set; } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/IHasAnonymousId.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/IHasAnonymousId.cs new file mode 100644 index 00000000..3c539770 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/IHasAnonymousId.cs @@ -0,0 +1,7 @@ +namespace EShopOnAbp.BasketService.Services.Dtos +{ + public interface IHasAnonymousId + { + Guid? AnonymousId { get; } + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/RemoveProductDto.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/RemoveProductDto.cs new file mode 100644 index 00000000..bd481712 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Dtos/RemoveProductDto.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.BasketService.Services.Dtos; + +public class RemoveProductDto : IHasAnonymousId +{ + public Guid ProductId { get; set; } + + public int? Count { get; set; } + + public Guid? AnonymousId { get; set; } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/IBasketAppService.cs b/services/basket/src/EShopOnAbp.BasketService/Services/IBasketAppService.cs new file mode 100644 index 00000000..bbe18e5a --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/IBasketAppService.cs @@ -0,0 +1,11 @@ +using EShopOnAbp.BasketService.Services.Dtos; +using Volo.Abp.Application.Services; + +namespace EShopOnAbp.BasketService.Services; + +public interface IBasketAppService : IApplicationService +{ + Task GetAsync(Guid? anonymousUserId); + Task AddProductAsync(AddProductDto input); + Task RemoveProductAsync(RemoveProductDto input); +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/IBasketProductService.cs b/services/basket/src/EShopOnAbp.BasketService/Services/IBasketProductService.cs new file mode 100644 index 00000000..1288112c --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/IBasketProductService.cs @@ -0,0 +1,12 @@ +using System; +using System.Threading.Tasks; +using EShopOnAbp.CatalogService.Products; +using JetBrains.Annotations; + +namespace EShopOnAbp.BasketService; + +public interface IBasketProductService +{ + [ItemNotNull] + Task GetAsync(Guid productId); +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Permissions/BasketServicePermissionDefinitionProvider.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Permissions/BasketServicePermissionDefinitionProvider.cs new file mode 100644 index 00000000..147464a5 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Permissions/BasketServicePermissionDefinitionProvider.cs @@ -0,0 +1,21 @@ +using EShopOnAbp.BasketService.Localization; +using Volo.Abp.Authorization.Permissions; +using Volo.Abp.Localization; + +namespace EShopOnAbp.BasketService.Services.Permissions +{ + public class BasketServicePermissionDefinitionProvider : PermissionDefinitionProvider + { + public override void Define(IPermissionDefinitionContext context) + { + var myGroup = context.AddGroup(BasketServicePermissions.GroupName); + //Define your own permissions here. Example: + //myGroup.AddPermission(BasketServicePermissions.MyPermission1, L("Permission:MyPermission1")); + } + + private static LocalizableString L(string name) + { + return LocalizableString.Create(name); + } + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/Services/Permissions/BasketServicePermissions.cs b/services/basket/src/EShopOnAbp.BasketService/Services/Permissions/BasketServicePermissions.cs new file mode 100644 index 00000000..877cf2f9 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/Services/Permissions/BasketServicePermissions.cs @@ -0,0 +1,10 @@ +namespace EShopOnAbp.BasketService.Services.Permissions +{ + public static class BasketServicePermissions + { + public const string GroupName = "BasketService"; + + //Add your own permission names. Example: + //public const string MyPermission1 = GroupName + ".MyPermission1"; + } +} \ No newline at end of file diff --git a/services/basket/src/EShopOnAbp.BasketService/appsettings.Development.json b/services/basket/src/EShopOnAbp.BasketService/appsettings.Development.json new file mode 100644 index 00000000..0c208ae9 --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/appsettings.Development.json @@ -0,0 +1,8 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/services/basket/src/EShopOnAbp.BasketService/appsettings.json b/services/basket/src/EShopOnAbp.BasketService/appsettings.json new file mode 100644 index 00000000..93adbecc --- /dev/null +++ b/services/basket/src/EShopOnAbp.BasketService/appsettings.json @@ -0,0 +1,49 @@ +{ + "App": { + "SelfUrl": "https://localhost:44355", + "CorsOrigins": "https://localhost:44372,https://localhost:44373,https://localhost:44335" + }, + "AuthServer": { + "Authority": "https://localhost:44330", + "RequireHttpsMetadata": "true", + "SwaggerClientId": "WebGateway_Swagger", + "SwaggerClientSecret": "1q2w3e*" + }, + "RemoteServices": { + "Catalog": { + "BaseUrl": "https://localhost:44354/", + "GrpcUrl": "http://localhost:81" + } + }, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft": "Warning", + "Microsoft.Hosting.Lifetime": "Information" + } + }, + "AllowedHosts": "*", + "ConnectionStrings": { + "AdministrationService": "User ID=postgres;Password=myPassw0rd;Host=localhost;Port=5432;Database=EShopOnAbp_Administration;Pooling=false;" + }, + "StringEncryption": { + "DefaultPassPhrase": "3PfxLgcuymUUbihz" + }, + "Redis": { + "Configuration": "localhost:6379" + }, + "RabbitMQ": { + "Connections": { + "Default": { + "HostName": "localhost" + } + }, + "EventBus": { + "ClientName": "EShopOnAbp_BasketService", + "ExchangeName": "EShopOnAbp" + } + }, + "ElasticSearch": { + "Url": "http://localhost:9200" + } +} \ No newline at end of file