Browse Source

Working on basket service

pull/37/head
Halil İbrahim Kalkan 5 years ago
parent
commit
add974f979
  1. 34
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs
  2. 2
      apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml
  3. 1
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj
  4. 8
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs
  5. 7
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.cshtml
  6. 13
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.cshtml.js
  7. 19
      apps/public-web/src/EShopOnAbp.PublicWeb/appsettings.json
  8. 40
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/client-proxies/basket-proxy.js
  9. 12
      services/basket/src/EShopOnAbp.BasketService.Application.Contracts/AddProductDto.cs
  10. 14
      services/basket/src/EShopOnAbp.BasketService.Application.Contracts/BasketDto.cs
  11. 13
      services/basket/src/EShopOnAbp.BasketService.Application.Contracts/BasketItemDto.cs
  12. 7
      services/basket/src/EShopOnAbp.BasketService.Application.Contracts/IBasketAppService.cs
  13. 10
      services/basket/src/EShopOnAbp.BasketService.Application.Contracts/RemoveProductDto.cs
  14. 82
      services/basket/src/EShopOnAbp.BasketService.Application/BasketAppService.cs
  15. 36
      services/basket/src/EShopOnAbp.BasketService.Application/BasketProductService.cs
  16. 6
      services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs
  17. 1
      services/basket/src/EShopOnAbp.BasketService.Application/EShopOnAbp.BasketService.Application.csproj
  18. 12
      services/basket/src/EShopOnAbp.BasketService.Application/IBasketProductService.cs
  19. 62
      services/basket/src/EShopOnAbp.BasketService.Domain/Basket.cs
  20. 20
      services/basket/src/EShopOnAbp.BasketService.Domain/BasketItem.cs
  21. 25
      services/basket/src/EShopOnAbp.BasketService.Domain/BasketRepository.cs
  22. 23
      services/basket/src/EShopOnAbp.BasketService.Domain/BasketServiceDomainModule.cs
  23. 1
      services/basket/src/EShopOnAbp.BasketService.Domain/EShopOnAbp.BasketService.Domain.csproj
  24. 12
      services/basket/src/EShopOnAbp.BasketService.Domain/IBasketRepository.cs
  25. 4
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/BasketServiceHttpApiClientModule.cs
  26. 39
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/ClientProxies/BasketClientProxy.Generated.cs
  27. 8
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/ClientProxies/BasketClientProxy.cs
  28. 133
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/ClientProxies/basket-generate-proxy.json
  29. 15
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs
  30. 5
      services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json
  31. 4
      services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs

34
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/BasketWidgetViewComponent.cs

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.UI.Widgets;
@ -13,36 +11,14 @@ public class BasketWidgetViewComponent : AbpViewComponent
{
private readonly IBasketAppService _basketAppService;
public BasketWidgetViewComponent()
public BasketWidgetViewComponent(IBasketAppService basketAppService)
{
//_basketAppService = basketAppService;
_basketAppService = basketAppService;
}
public async Task<IViewComponentResult> InvokeAsync()
{
var basketModel = new BasketViewModel();
basketModel.Items.Add(new BasketItemViewModel{ImageName = "asus.jpg", ProductName = "test-one", Count = 1, TotalPrice = 19});
basketModel.Items.Add(new BasketItemViewModel{ImageName = "lego.jpg", ProductName = "test-two", Count = 2, TotalPrice = 4});
basketModel.TotalPrice = 123;
return View("~/Components/Basket/Default.cshtml", basketModel);
var basketDto = await _basketAppService.GetAsync();
return View("~/Components/Basket/Default.cshtml", basketDto);
}
}
public class BasketViewModel
{
public float TotalPrice { get; set; }
public List<BasketItemViewModel> Items { get; set; }
public BasketViewModel()
{
Items = new List<BasketItemViewModel>();
}
}
public class BasketItemViewModel
{
public string ProductName { get; set; }
public int Count { get; set; }
public float TotalPrice { get; set; }
public string ImageName { get; set; }
}

2
apps/public-web/src/EShopOnAbp.PublicWeb/Components/Basket/Default.cshtml

@ -1,4 +1,4 @@
@model EShopOnAbp.PublicWeb.Components.Basket.BasketViewModel
@model EShopOnAbp.BasketService.BasketDto
<div>
@if (!Model.Items.Any())
{

1
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj

@ -6,6 +6,7 @@
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.DataProtection.StackExchangeRedis" Version="6.0.0" />
<PackageReference Include="Yarp.ReverseProxy" Version="1.0.0" />
</ItemGroup>
<ItemGroup>

8
apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs

@ -102,7 +102,8 @@ namespace EShopOnAbp.PublicWeb
options.Scope.Add("email");
options.Scope.Add("phone");
options.Scope.Add("AdministrationService");
// options.Scope.Add("ProductService");
options.Scope.Add("BasketService");
options.Scope.Add("CatalogService");
});
var redis = ConnectionMultiplexer.Connect(configuration["Redis:Configuration"]);
@ -120,6 +121,10 @@ namespace EShopOnAbp.PublicWeb
{
options.Contributors.Add(new EShopOnAbpPublicWebToolbarContributor());
});
context.Services
.AddReverseProxy()
.LoadFromConfig(configuration.GetSection("ReverseProxy"));
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
@ -154,6 +159,7 @@ namespace EShopOnAbp.PublicWeb
app.UseAuthorization();
app.UseConfiguredEndpoints(endpoints =>
{
endpoints.MapReverseProxy();
// endpoints.MapMetrics();
});
}

7
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.cshtml

@ -8,7 +8,10 @@
@section styles{
<abp-style src="/Pages/Catalog.css"/>
}
@section scripts {
<abp-script src="/client-proxies/basket-proxy.js" />
<abp-script src="/Pages/Catalog.cshtml.js" />
}
<div class="row">
<div class="col-lg-9">
<h3 class="pt-5 pb-4 text-center">Our Products</h3>
@ -22,7 +25,7 @@
@if ((i * productsColumnSize) + j < Model.Products.Count)
{
var product = Model.Products[(i * productsColumnSize) + j];
<div class="product-list-item">
<div class="product-list-item" data-product-id="@product.Id.ToString()">
@if (!product.ImageName.IsNullOrEmpty())
{
<img src="/product-images/@product.ImageName"/>

13
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.cshtml.js

@ -0,0 +1,13 @@
(function(){
$(function(){
$('.product-list-item').click(function(){
var $this = $(this);
var productId = $this.attr('data-product-id');
eShopOnAbp.basketService.basket.addProduct({
productId: productId
}).then(function(){
abp.notify.success("Added product to your basket.", "Successfully added");
});
});
})
})();

19
apps/public-web/src/EShopOnAbp.PublicWeb/appsettings.json

@ -40,5 +40,24 @@
"RequireHttpsMetadata": "true",
"ClientId": "PublicWeb",
"ClientSecret": "1q2w3e*"
},
"ReverseProxy": {
"Routes": {
"route1" : {
"ClusterId": "cluster1",
"Match": {
"Path": "/api/{**anypath}"
}
}
},
"Clusters": {
"cluster1": {
"Destinations": {
"destination1": {
"Address": "https://localhost:44373/"
}
}
}
}
}
}

40
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/client-proxies/basket-proxy.js

@ -0,0 +1,40 @@
/* This file is automatically generated by ABP framework to use MVC Controllers from javascript. */
// module basket
(function(){
// controller eShopOnAbp.basketService.basket
(function(){
abp.utils.createNamespace(window, 'eShopOnAbp.basketService.basket');
eShopOnAbp.basketService.basket.get = function(ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/basket/basket',
type: 'GET'
}, ajaxParams));
};
eShopOnAbp.basketService.basket.addProduct = function(input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/basket/basket/product',
type: 'POST',
data: JSON.stringify(input)
}, ajaxParams));
};
eShopOnAbp.basketService.basket.removeProduct = function(input, ajaxParams) {
return abp.ajax($.extend(true, {
url: abp.appPath + 'api/basket/basket/product' + abp.utils.buildQueryString([{ name: 'productId', value: input.productId }, { name: 'count', value: input.count }]) + '',
type: 'DELETE'
}, ajaxParams));
};
})();
})();

12
services/basket/src/EShopOnAbp.BasketService.Application.Contracts/AddProductDto.cs

@ -0,0 +1,12 @@
using System;
using System.ComponentModel.DataAnnotations;
namespace EShopOnAbp.BasketService;
public class AddProductDto
{
public Guid ProductId { get; set; }
[Range(1, int.MaxValue)]
public int Count { get; set; } = 1;
}

14
services/basket/src/EShopOnAbp.BasketService.Application.Contracts/BasketDto.cs

@ -0,0 +1,14 @@
using System.Collections.Generic;
namespace EShopOnAbp.BasketService;
public class BasketDto
{
public float TotalPrice { get; set; }
public List<BasketItemDto> Items { get; set; }
public BasketDto()
{
Items = new List<BasketItemDto>();
}
}

13
services/basket/src/EShopOnAbp.BasketService.Application.Contracts/BasketItemDto.cs

@ -0,0 +1,13 @@
using System;
namespace EShopOnAbp.BasketService;
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; }
}

7
services/basket/src/EShopOnAbp.BasketService.Application.Contracts/IBasketAppService.cs

@ -1,8 +1,11 @@
using Volo.Abp.Application.Services;
using System.Threading.Tasks;
using Volo.Abp.Application.Services;
namespace EShopOnAbp.BasketService;
public interface IBasketAppService : IApplicationService
{
Task<BasketDto> GetAsync();
Task<BasketDto> AddProductAsync(AddProductDto input);
Task<BasketDto> RemoveProductAsync(RemoveProductDto input);
}

10
services/basket/src/EShopOnAbp.BasketService.Application.Contracts/RemoveProductDto.cs

@ -0,0 +1,10 @@
using System;
namespace EShopOnAbp.BasketService;
public class RemoveProductDto
{
public Guid ProductId { get; set; }
public int? Count { get; set; }
}

82
services/basket/src/EShopOnAbp.BasketService.Application/BasketAppService.cs

@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authorization;
using Volo.Abp.Users;
using EShopOnAbp.CatalogService.Products;
namespace EShopOnAbp.BasketService;
[Authorize]
public class BasketAppService : BasketServiceAppService, IBasketAppService
{
private readonly IBasketRepository _basketRepository;
private readonly IBasketProductService _basketProductService;
public BasketAppService(
IBasketRepository basketRepository,
IBasketProductService basketProductService)
{
_basketRepository = basketRepository;
_basketProductService = basketProductService;
}
public async Task<BasketDto> GetAsync()
{
var basket = await _basketRepository.GetAsync(CurrentUser.GetId());
return await GetBasketDtoAsync(basket);
}
public async Task<BasketDto> AddProductAsync(AddProductDto input)
{
var basket = await _basketRepository.GetAsync(CurrentUser.GetId());
var product = await _basketProductService.GetAsync(input.ProductId);
basket.AddProduct(product.Id);
return await GetBasketDtoAsync(basket);
}
public async Task<BasketDto> RemoveProductAsync(RemoveProductDto input)
{
var basket = await _basketRepository.GetAsync(CurrentUser.GetId());
var product = await _basketProductService.GetAsync(input.ProductId);
basket.RemoveProduct(product.Id, input.Count);
return await GetBasketDtoAsync(basket);
}
private async Task<BasketDto> GetBasketDtoAsync(Basket basket)
{
var products = new Dictionary<Guid, ProductDto>();
var basketDto = new BasketDto();
foreach (var basketItem in basket.Items)
{
var basketItemDto = new BasketItemDto
{
ProductId = basketItem.ProductId,
Count = basketItem.Count
};
var productDto = products.GetOrDefault(basketItem.ProductId);
if (productDto == null)
{
productDto = await _basketProductService.GetAsync(basketItem.ProductId);
products[productDto.Id] = productDto;
}
basketItemDto.ProductCode = productDto.Code;
basketItemDto.ImageName = productDto.ImageName;
basketItemDto.ProductName = productDto.Name;
basketItemDto.TotalPrice = productDto.Price * basketItemDto.Count;
}
basketDto.TotalPrice = basketDto.Items.Sum(x => x.TotalPrice);
return basketDto;
}
}

36
services/basket/src/EShopOnAbp.BasketService.Application/BasketProductService.cs

@ -0,0 +1,36 @@
using System;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.Products;
using Volo.Abp;
using Volo.Abp.Caching;
using Volo.Abp.DependencyInjection;
namespace EShopOnAbp.BasketService;
public class BasketProductService : IBasketProductService, ITransientDependency
{
private readonly IProductAppService _productAppService;
private readonly IDistributedCache<ProductDto, Guid> _cache;
public BasketProductService(
IProductAppService productAppService,
IDistributedCache<ProductDto, Guid> cache)
{
_productAppService = productAppService;
_cache = cache;
}
public async Task<ProductDto> GetAsync(Guid productId)
{
return await _cache.GetOrAddAsync(
productId,
() => GetProductAsync(productId)
);
}
private Task<ProductDto> GetProductAsync(Guid productId)
{
return _productAppService.GetAsync(productId) ??
throw new UserFriendlyException("Could not find the product!"); //TODO: Business exception with localization;
}
}

6
services/basket/src/EShopOnAbp.BasketService.Application/BasketServiceApplicationModule.cs

@ -1,4 +1,5 @@
using Volo.Abp.Application;
using EShopOnAbp.CatalogService;
using Volo.Abp.Application;
using Volo.Abp.AutoMapper;
using Volo.Abp.Modularity;
@ -8,7 +9,8 @@ namespace EShopOnAbp.BasketService
typeof(BasketServiceDomainModule),
typeof(BasketServiceApplicationContractsModule),
typeof(AbpDddApplicationModule),
typeof(AbpAutoMapperModule)
typeof(AbpAutoMapperModule),
typeof(CatalogServiceHttpApiClientModule)
)]
public class BasketServiceApplicationModule : AbpModule
{

1
services/basket/src/EShopOnAbp.BasketService.Application/EShopOnAbp.BasketService.Application.csproj

@ -10,6 +10,7 @@
<ItemGroup>
<ProjectReference Include="..\EShopOnAbp.BasketService.Domain\EShopOnAbp.BasketService.Domain.csproj" />
<ProjectReference Include="..\EShopOnAbp.BasketService.Application.Contracts\EShopOnAbp.BasketService.Application.Contracts.csproj" />
<ProjectReference Include="..\..\..\catalog\src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj" />
</ItemGroup>
<ItemGroup>

12
services/basket/src/EShopOnAbp.BasketService.Application/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<ProductDto> GetAsync(Guid productId);
}

62
services/basket/src/EShopOnAbp.BasketService.Domain/Basket.cs

@ -0,0 +1,62 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp.Domain.Entities;
namespace EShopOnAbp.BasketService;
public class Basket : AggregateRoot<Guid>
{
public List<BasketItem> Items { get; private set; }
private Basket()
{
}
public Basket(Guid id)
: base(id)
{
Items = new List<BasketItem>();
}
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;
}
}

20
services/basket/src/EShopOnAbp.BasketService.Domain/BasketItem.cs

@ -0,0 +1,20 @@
using System;
namespace EShopOnAbp.BasketService;
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;
}
}

25
services/basket/src/EShopOnAbp.BasketService.Domain/BasketRepository.cs

@ -0,0 +1,25 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Caching;
namespace EShopOnAbp.BasketService;
public class BasketRepository : IBasketRepository
{
private readonly IDistributedCache<Basket, Guid> _cache;
public BasketRepository(IDistributedCache<Basket, Guid> cache)
{
_cache = cache;
}
public async Task<Basket> 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);
}
}

23
services/basket/src/EShopOnAbp.BasketService.Domain/BasketServiceDomainModule.cs

@ -1,16 +1,35 @@
using Volo.Abp.Domain;
using System;
using Microsoft.Extensions.Caching.Distributed;
using Volo.Abp.Caching;
using Volo.Abp.Domain;
using Volo.Abp.Modularity;
namespace EShopOnAbp.BasketService
{
[DependsOn(
typeof(BasketServiceDomainSharedModule),
typeof(AbpDddDomainModule)
typeof(AbpDddDomainModule),
typeof(AbpCachingModule)
)]
public class BasketServiceDomainModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpDistributedCacheOptions>(options =>
{
options.CacheConfigurators.Add(cacheName =>
{
if (cacheName == CacheNameAttribute.GetCacheName(typeof(Basket)))
{
return new DistributedCacheEntryOptions
{
SlidingExpiration = TimeSpan.FromDays(7)
};
}
return null;
});
});
}
}
}

1
services/basket/src/EShopOnAbp.BasketService.Domain/EShopOnAbp.BasketService.Domain.csproj

@ -13,6 +13,7 @@
<ItemGroup>
<PackageReference Include="Volo.Abp.Ddd.Domain" Version="5.0.0-rc.1" />
<PackageReference Include="Volo.Abp.Caching" Version="5.0.0-rc.1" />
</ItemGroup>
</Project>

12
services/basket/src/EShopOnAbp.BasketService.Domain/IBasketRepository.cs

@ -0,0 +1,12 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
namespace EShopOnAbp.BasketService;
public interface IBasketRepository : IRepository
{
Task<Basket> GetAsync(Guid id);
Task UpdateAsync(Basket basket);
}

4
services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/BasketServiceHttpApiClientModule.cs

@ -11,11 +11,11 @@ namespace EShopOnAbp.BasketService
)]
public class BasketServiceHttpApiClientModule : AbpModule
{
public const string RemoteServiceName = "Default";
public const string RemoteServiceName = "Basket";
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddHttpClientProxies(
context.Services.AddStaticHttpClientProxies(
typeof(BasketServiceApplicationContractsModule).Assembly,
RemoteServiceName
);

39
services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/ClientProxies/BasketClientProxy.Generated.cs

@ -0,0 +1,39 @@
// 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.BasketService;
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.BasketService.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IBasketAppService), typeof(BasketClientProxy))]
public partial class BasketClientProxy : ClientProxyBase<IBasketAppService>, IBasketAppService
{
public virtual async Task<BasketDto> GetAsync()
{
return await RequestAsync<BasketDto>(nameof(GetAsync));
}
public virtual async Task<BasketDto> AddProductAsync(AddProductDto input)
{
return await RequestAsync<BasketDto>(nameof(AddProductAsync), new ClientProxyRequestTypeValue
{
{ typeof(AddProductDto), input }
});
}
public virtual async Task<BasketDto> RemoveProductAsync(RemoveProductDto input)
{
return await RequestAsync<BasketDto>(nameof(RemoveProductAsync), new ClientProxyRequestTypeValue
{
{ typeof(RemoveProductDto), input }
});
}
}
}

8
services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/ClientProxies/BasketClientProxy.cs

@ -0,0 +1,8 @@
// This file is part of BasketClientProxy, you can customize it here
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.BasketService.ClientProxies
{
public partial class BasketClientProxy
{
}
}

133
services/basket/src/EShopOnAbp.BasketService.HttpApi.Client/ClientProxies/basket-generate-proxy.json

@ -0,0 +1,133 @@
{
"modules": {
"basket": {
"rootPath": "basket",
"remoteServiceName": "Basket",
"controllers": {
"EShopOnAbp.BasketService.BasketAppService": {
"controllerName": "Basket",
"controllerGroupName": "Basket",
"type": "EShopOnAbp.BasketService.BasketAppService",
"interfaces": [
{
"type": "Volo.Abp.Validation.IValidationEnabled"
},
{
"type": "Volo.Abp.Auditing.IAuditingEnabled"
},
{
"type": "Volo.Abp.GlobalFeatures.IGlobalFeatureCheckingEnabled"
},
{
"type": "EShopOnAbp.BasketService.IBasketAppService"
}
],
"actions": {
"GetAsync": {
"uniqueName": "GetAsync",
"name": "GetAsync",
"httpMethod": "GET",
"url": "api/basket/basket",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "EShopOnAbp.BasketService.BasketDto",
"typeSimple": "EShopOnAbp.BasketService.BasketDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.BasketService.IBasketAppService"
},
"AddProductAsyncByInput": {
"uniqueName": "AddProductAsyncByInput",
"name": "AddProductAsync",
"httpMethod": "POST",
"url": "api/basket/basket/product",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "EShopOnAbp.BasketService.AddProductDto, EShopOnAbp.BasketService.Application.Contracts",
"type": "EShopOnAbp.BasketService.AddProductDto",
"typeSimple": "EShopOnAbp.BasketService.AddProductDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "EShopOnAbp.BasketService.AddProductDto",
"typeSimple": "EShopOnAbp.BasketService.AddProductDto",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "EShopOnAbp.BasketService.BasketDto",
"typeSimple": "EShopOnAbp.BasketService.BasketDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.BasketService.IBasketAppService"
},
"RemoveProductAsyncByInput": {
"uniqueName": "RemoveProductAsyncByInput",
"name": "RemoveProductAsync",
"httpMethod": "DELETE",
"url": "api/basket/basket/product",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "EShopOnAbp.BasketService.RemoveProductDto, EShopOnAbp.BasketService.Application.Contracts",
"type": "EShopOnAbp.BasketService.RemoveProductDto",
"typeSimple": "EShopOnAbp.BasketService.RemoveProductDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "ProductId",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "Count",
"jsonName": null,
"type": "System.Int32?",
"typeSimple": "number?",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
}
],
"returnValue": {
"type": "EShopOnAbp.BasketService.BasketDto",
"typeSimple": "EShopOnAbp.BasketService.BasketDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.BasketService.IBasketAppService"
}
}
}
}
}
},
"types": {}
}

15
services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/BasketServiceHttpApiHostModule.cs

@ -8,6 +8,7 @@ using System;
using System.Collections.Generic;
using System.Linq;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.Modularity;
namespace EShopOnAbp.BasketService
@ -21,10 +22,12 @@ namespace EShopOnAbp.BasketService
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Microsoft.IdentityModel.Logging.IdentityModelEventSource.ShowPII = true;
var configuration = context.Services.GetConfiguration();
var hostingEnvironment = context.Services.GetHostingEnvironment();
JwtBearerConfigurationHelper.Configure(context, "BasketService");
JwtBearerConfigurationHelper.Configure(context, "AdministrationService");
// SwaggerConfigurationHelper.Configure(context, "Basket Service API");
SwaggerWithAuthConfigurationHelper.Configure(
@ -55,6 +58,16 @@ namespace EShopOnAbp.BasketService
.AllowCredentials();
});
});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(
typeof(BasketServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "basket";
opts.RemoteServiceName = "Basket";
});
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)

5
services/basket/src/EShopOnAbp.BasketService.HttpApi.Host/appsettings.json

@ -9,6 +9,11 @@
"SwaggerClientId": "BasketService_Swagger",
"SwaggerClientSecret": "1q2w3e*"
},
"RemoteServices": {
"Catalog": {
"BaseUrl": "https://localhost:44354/"
}
},
"Logging": {
"LogLevel": {
"Default": "Information",

4
services/identity/src/EShopOnAbp.IdentityService.HttpApi.Host/DbMigrations/IdentityServerDataSeeder.cs

@ -216,7 +216,9 @@ namespace EShopOnAbp.IdentityService.DbMigrations
name: "PublicWeb",
scopes: commonScopes.Union(new[]
{
"AdministrationService"
"AdministrationService",
"CatalogService",
"BasketService"
}),
grantTypes: new[] { "hybrid" },
secret: "1q2w3e*".Sha256(),

Loading…
Cancel
Save