Browse Source

Show products on the public web page.

pull/37/head
Halil İbrahim Kalkan 5 years ago
parent
commit
563efe921e
  1. 1
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbp.PublicWeb.csproj
  2. 5
      apps/public-web/src/EShopOnAbp.PublicWeb/EShopOnAbpPublicWebModule.cs
  3. 18
      apps/public-web/src/EShopOnAbp.PublicWeb/Menus/EShopOnAbpPublicWebMenuContributor.cs
  4. 2
      apps/public-web/src/EShopOnAbp.PublicWeb/Menus/EShopOnAbpPublicWebMenus.cs
  5. 45
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.cshtml
  6. 17
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.cshtml.cs
  7. 30
      apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css
  8. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/asus.jpg
  9. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/beats.jpg
  10. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/bluecat.jpg
  11. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/lego.jpg
  12. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/nikon.jpg
  13. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/noimage.jpg
  14. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/oki.jpg
  15. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/playstation.jpg
  16. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/rampage.jpg
  17. BIN
      apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/sunny.jpg
  18. 5
      services/catalog/src/EShopOnAbp.CatalogService.Application/CatalogServiceApplicationAutoMapperProfile.cs
  19. 1
      services/catalog/src/EShopOnAbp.CatalogService.Application/Products/ProductAppService.cs
  20. 4
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/CatalogServiceHttpApiClientModule.cs
  21. 64
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/ProductClientProxy.Generated.cs
  22. 8
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/ProductClientProxy.cs
  23. 23
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/PublicProductClientProxy.Generated.cs
  24. 8
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/PublicProductClientProxy.cs
  25. 312
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/catalog-generate-proxy.json
  26. 18
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs
  27. 13
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationChecker.cs
  28. 3
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationEventHandler.cs
  29. 110
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/ProductServiceDataSeeder.cs
  30. 2
      services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json
  31. 8
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs
  32. 8
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs
  33. 1
      services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs
  34. 3
      shared/EShopOnAbp.Shared.Localization/Localization/EShopOnAbp/en.json

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

@ -22,6 +22,7 @@
<ItemGroup>
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Hosting.AspNetCore\EShopOnAbp.Shared.Hosting.AspNetCore.csproj" />
<ProjectReference Include="..\..\..\..\shared\EShopOnAbp.Shared.Localization\EShopOnAbp.Shared.Localization.csproj" />
<ProjectReference Include="..\..\..\..\services\catalog\src\EShopOnAbp.CatalogService.HttpApi.Client\EShopOnAbp.CatalogService.HttpApi.Client.csproj" />
<!-- <ProjectReference Include="..\..\..\..\services\product\src\MyCompanyName.MyProjectName.ProductService.HttpApi.Client\MyCompanyName.MyProjectName.ProductService.HttpApi.Client.csproj" />-->
</ItemGroup>

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

@ -1,4 +1,5 @@
using System;
using EShopOnAbp.CatalogService;
using EShopOnAbp.Localization;
using EShopOnAbp.PublicWeb.Menus;
using EShopOnAbp.Shared.Hosting.AspNetCore;
@ -37,8 +38,8 @@ namespace EShopOnAbp.PublicWeb
typeof(AbpAccountHttpApiModule),
typeof(AbpAccountHttpApiClientModule),
typeof(EShopOnAbpSharedHostingAspNetCoreModule),
typeof(EShopOnAbpSharedLocalizationModule)
// typeof(ProductServiceHttpApiClientModule)
typeof(EShopOnAbpSharedLocalizationModule),
typeof(CatalogServiceHttpApiClientModule)
)]
public class EShopOnAbpPublicWebModule : AbpModule
{

18
apps/public-web/src/EShopOnAbp.PublicWeb/Menus/EShopOnAbpPublicWebMenuContributor.cs

@ -45,15 +45,15 @@ namespace EShopOnAbp.PublicWeb.Menus
)
);
// Products
// context.Menu.AddItem(
// new ApplicationMenuItem(
// EShopOnAbpPublicWebMenus.ProductPage,
// "Products",
// "/Products",
// icon: "fa fa-product-hunt",
// order: 1
// )
// );
context.Menu.AddItem(
new ApplicationMenuItem(
EShopOnAbpPublicWebMenus.Catalog,
l["Catalog"],
"/Catalog",
icon: "fa fa-product-hunt",
order: 1
)
);
return Task.CompletedTask;
}

2
apps/public-web/src/EShopOnAbp.PublicWeb/Menus/EShopOnAbpPublicWebMenus.cs

@ -5,6 +5,6 @@
private const string Prefix = "EShopOnAbp.Public";
public const string HomePage = Prefix + ".HomePage";
// public const string ProductPage = Prefix + ".ProductPage";
public const string Catalog = Prefix + ".Catalog";
}
}

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

@ -1,3 +1,46 @@
@page
@model EShopOnAbp.PublicWeb.Pages.Catalog
<h2>Catalog page!</h2>
@{
const int columnSize = 3;
}
@section styles{
<abp-style src="/Pages/Catalog.css" />
}
<h3 class="pt-5 pb-4 text-center">Our Products</h3>
<div class="product-list">
@for (int i = 0; i < Math.Ceiling(Model.Products.Count / (double)columnSize); i++)
{
<abp-row>
@for (int j = 0; j < columnSize; j++)
{
<abp-column size-lg="_4" size-md="_6" size-sm="_12">
@if ((i * columnSize) + j < Model.Products.Count)
{
var product = Model.Products[(i * columnSize) + j];
<div class="product-list-item">
@if (!product.ImageName.IsNullOrEmpty())
{
<img src="/product-images/@product.ImageName" />
}
else
{
<img src="/product-images/noimage.jpg" />
}
<div class="row mt-5">
<div class="col">
<div class="product-info-box">
<h6>@product.Name</h6>
<em class="d-block text-muted">@product.Code - Stock count: @product.StockCount</em>
</div>
</div>
<div class="col-auto text-right text-danger">
<strong class="product-price">$@product.Price</strong>
</div>
</div>
</div>
}
</abp-column>
}
</abp-row>
}
</div>

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

@ -1,11 +1,22 @@
using Microsoft.AspNetCore.Mvc.RazorPages;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc.RazorPages;
using EShopOnAbp.CatalogService.Products;
namespace EShopOnAbp.PublicWeb.Pages;
public class Catalog : PageModel
{
public void OnGet()
public IReadOnlyList<ProductDto> Products { get; private set; }
private readonly IPublicProductAppService _productAppService;
public Catalog(IPublicProductAppService productAppService)
{
_productAppService = productAppService;
}
public async Task OnGetAsync()
{
Products = (await _productAppService.GetListAsync()).Items;
}
}

30
apps/public-web/src/EShopOnAbp.PublicWeb/Pages/Catalog.css

@ -0,0 +1,30 @@
body {
background-color: #f9f9f9;
}
.product-list-item {
background-color: #fff;
padding: 2em;
border: 1px solid #eee;
border-radius: 3px;
box-shadow: 0 0 10px rgba(0, 0, 0, .05);
margin-bottom: 2em;
transition: all .2s;
}
.product-list-item:hover {
box-shadow: 0 0 20px rgba(0, 0, 0, .1);
cursor: pointer;
}
.product-list-item img {
width: 100%;
}
.product-list-item .text-muted {
opacity: .8
}
.product-info-box {
min-height: 80px;
}

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/asus.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/beats.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/bluecat.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/lego.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/nikon.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/noimage.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/oki.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/playstation.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/rampage.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
apps/public-web/src/EShopOnAbp.PublicWeb/wwwroot/product-images/sunny.jpg

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

5
services/catalog/src/EShopOnAbp.CatalogService.Application/CatalogServiceApplicationAutoMapperProfile.cs

@ -1,4 +1,5 @@
using AutoMapper;
using EShopOnAbp.CatalogService.Products;
namespace EShopOnAbp.CatalogService
{
@ -6,9 +7,7 @@ namespace EShopOnAbp.CatalogService
{
public CatalogServiceApplicationAutoMapperProfile()
{
/* You can configure your AutoMapper mapping configuration here.
* Alternatively, you can split your mapping configurations
* into multiple profile classes for a better organization. */
CreateMap<Product, ProductDto>();
}
}
}

1
services/catalog/src/EShopOnAbp.CatalogService.Application/Products/ProductAppService.cs

@ -23,6 +23,7 @@ namespace EShopOnAbp.CatalogService.Products
_productRepository = productRepository;
}
//TODO: Is this method used?
public async Task<PagedResultDto<ProductDto>> GetListPagedAsync(PagedAndSortedResultRequestDto input)
{
var queryable = await _productRepository.GetQueryableAsync();

4
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/CatalogServiceHttpApiClientModule.cs

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

64
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/ProductClientProxy.Generated.cs

@ -0,0 +1,64 @@
// 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.CatalogService.Products;
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.CatalogService.Products.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IProductAppService), typeof(ProductClientProxy))]
public partial class ProductClientProxy : ClientProxyBase<IProductAppService>, IProductAppService
{
public virtual async Task<PagedResultDto<ProductDto>> GetListPagedAsync(PagedAndSortedResultRequestDto input)
{
return await RequestAsync<PagedResultDto<ProductDto>>(nameof(GetListPagedAsync), new ClientProxyRequestTypeValue
{
{ typeof(PagedAndSortedResultRequestDto), input }
});
}
public virtual async Task<ListResultDto<ProductDto>> GetListAsync()
{
return await RequestAsync<ListResultDto<ProductDto>>(nameof(GetListAsync));
}
public virtual async Task<ProductDto> GetAsync(Guid id)
{
return await RequestAsync<ProductDto>(nameof(GetAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id }
});
}
public virtual async Task<ProductDto> CreateAsync(CreateProductDto input)
{
return await RequestAsync<ProductDto>(nameof(CreateAsync), new ClientProxyRequestTypeValue
{
{ typeof(CreateProductDto), input }
});
}
public virtual async Task<ProductDto> UpdateAsync(Guid id, UpdateProductDto input)
{
return await RequestAsync<ProductDto>(nameof(UpdateAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id },
{ typeof(UpdateProductDto), input }
});
}
public virtual async Task DeleteAsync(Guid id)
{
await RequestAsync(nameof(DeleteAsync), new ClientProxyRequestTypeValue
{
{ typeof(Guid), id }
});
}
}
}

8
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/ProductClientProxy.cs

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

23
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/PublicProductClientProxy.Generated.cs

@ -0,0 +1,23 @@
// 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.CatalogService.Products;
// ReSharper disable once CheckNamespace
namespace EShopOnAbp.CatalogService.Products.ClientProxies
{
[Dependency(ReplaceServices = true)]
[ExposeServices(typeof(IPublicProductAppService), typeof(PublicProductClientProxy))]
public partial class PublicProductClientProxy : ClientProxyBase<IPublicProductAppService>, IPublicProductAppService
{
public virtual async Task<ListResultDto<ProductDto>> GetListAsync()
{
return await RequestAsync<ListResultDto<ProductDto>>(nameof(GetListAsync));
}
}
}

8
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/PublicProductClientProxy.cs

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

312
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Client/ClientProxies/catalog-generate-proxy.json

@ -0,0 +1,312 @@
{
"modules": {
"catalog": {
"rootPath": "catalog",
"remoteServiceName": "Catalog",
"controllers": {
"EShopOnAbp.CatalogService.Products.ProductAppService": {
"controllerName": "Product",
"controllerGroupName": "Product",
"type": "EShopOnAbp.CatalogService.Products.ProductAppService",
"interfaces": [
{
"type": "Volo.Abp.Validation.IValidationEnabled"
},
{
"type": "Volo.Abp.Auditing.IAuditingEnabled"
},
{
"type": "Volo.Abp.GlobalFeatures.IGlobalFeatureCheckingEnabled"
},
{
"type": "EShopOnAbp.CatalogService.Products.IProductAppService"
}
],
"actions": {
"GetListPagedAsyncByInput": {
"uniqueName": "GetListPagedAsyncByInput",
"name": "GetListPagedAsync",
"httpMethod": "GET",
"url": "api/catalog/product/paged",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto, Volo.Abp.Ddd.Application.Contracts",
"type": "Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto",
"typeSimple": "Volo.Abp.Application.Dtos.PagedAndSortedResultRequestDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "Sorting",
"jsonName": null,
"type": "System.String",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "SkipCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
},
{
"nameOnMethod": "input",
"name": "MaxResultCount",
"jsonName": null,
"type": "System.Int32",
"typeSimple": "number",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "ModelBinding",
"descriptorName": "input"
}
],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.PagedResultDto<EShopOnAbp.CatalogService.Products.ProductDto>",
"typeSimple": "Volo.Abp.Application.Dtos.PagedResultDto<EShopOnAbp.CatalogService.Products.ProductDto>"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.CatalogService.Products.IProductAppService"
},
"GetListAsync": {
"uniqueName": "GetListAsync",
"name": "GetListAsync",
"httpMethod": "GET",
"url": "api/catalog/product",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.ListResultDto<EShopOnAbp.CatalogService.Products.ProductDto>",
"typeSimple": "Volo.Abp.Application.Dtos.ListResultDto<EShopOnAbp.CatalogService.Products.ProductDto>"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.CatalogService.Products.IProductAppService"
},
"GetAsyncById": {
"uniqueName": "GetAsyncById",
"name": "GetAsync",
"httpMethod": "GET",
"url": "api/catalog/product/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "EShopOnAbp.CatalogService.Products.ProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.ProductDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.CatalogService.Products.IProductAppService"
},
"CreateAsyncByInput": {
"uniqueName": "CreateAsyncByInput",
"name": "CreateAsync",
"httpMethod": "POST",
"url": "api/catalog/product",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "input",
"typeAsString": "EShopOnAbp.CatalogService.Products.CreateProductDto, EShopOnAbp.CatalogService.Application.Contracts",
"type": "EShopOnAbp.CatalogService.Products.CreateProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.CreateProductDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "EShopOnAbp.CatalogService.Products.CreateProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.CreateProductDto",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "EShopOnAbp.CatalogService.Products.ProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.ProductDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.CatalogService.Products.IProductAppService"
},
"UpdateAsyncByIdAndInput": {
"uniqueName": "UpdateAsyncByIdAndInput",
"name": "UpdateAsync",
"httpMethod": "PUT",
"url": "api/catalog/product/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
},
{
"name": "input",
"typeAsString": "EShopOnAbp.CatalogService.Products.UpdateProductDto, EShopOnAbp.CatalogService.Application.Contracts",
"type": "EShopOnAbp.CatalogService.Products.UpdateProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.UpdateProductDto",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
},
{
"nameOnMethod": "input",
"name": "input",
"jsonName": null,
"type": "EShopOnAbp.CatalogService.Products.UpdateProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.UpdateProductDto",
"isOptional": false,
"defaultValue": null,
"constraintTypes": null,
"bindingSourceId": "Body",
"descriptorName": ""
}
],
"returnValue": {
"type": "EShopOnAbp.CatalogService.Products.ProductDto",
"typeSimple": "EShopOnAbp.CatalogService.Products.ProductDto"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.CatalogService.Products.IProductAppService"
},
"DeleteAsyncById": {
"uniqueName": "DeleteAsyncById",
"name": "DeleteAsync",
"httpMethod": "DELETE",
"url": "api/catalog/product/{id}",
"supportedVersions": [],
"parametersOnMethod": [
{
"name": "id",
"typeAsString": "System.Guid, System.Private.CoreLib",
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null
}
],
"parameters": [
{
"nameOnMethod": "id",
"name": "id",
"jsonName": null,
"type": "System.Guid",
"typeSimple": "string",
"isOptional": false,
"defaultValue": null,
"constraintTypes": [],
"bindingSourceId": "Path",
"descriptorName": ""
}
],
"returnValue": {
"type": "System.Void",
"typeSimple": "System.Void"
},
"allowAnonymous": false,
"implementFrom": "EShopOnAbp.CatalogService.Products.IProductAppService"
}
}
},
"EShopOnAbp.CatalogService.Products.PublicProductAppService": {
"controllerName": "PublicProduct",
"controllerGroupName": "PublicProduct",
"type": "EShopOnAbp.CatalogService.Products.PublicProductAppService",
"interfaces": [
{
"type": "Volo.Abp.Validation.IValidationEnabled"
},
{
"type": "Volo.Abp.Auditing.IAuditingEnabled"
},
{
"type": "Volo.Abp.GlobalFeatures.IGlobalFeatureCheckingEnabled"
},
{
"type": "EShopOnAbp.CatalogService.Products.IPublicProductAppService"
}
],
"actions": {
"GetListAsync": {
"uniqueName": "GetListAsync",
"name": "GetListAsync",
"httpMethod": "GET",
"url": "api/catalog/public-product",
"supportedVersions": [],
"parametersOnMethod": [],
"parameters": [],
"returnValue": {
"type": "Volo.Abp.Application.Dtos.ListResultDto<EShopOnAbp.CatalogService.Products.ProductDto>",
"typeSimple": "Volo.Abp.Application.Dtos.ListResultDto<EShopOnAbp.CatalogService.Products.ProductDto>"
},
"allowAnonymous": null,
"implementFrom": "EShopOnAbp.CatalogService.Products.IPublicProductAppService"
}
}
}
}
}
},
"types": {}
}

18
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/CatalogServiceHttpApiHostModule.cs

@ -11,8 +11,10 @@ using System.Linq;
using EShopOnAbp.CatalogService.MongoDB;
using Volo.Abp;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Uow;
using Volo.Abp.Modularity;
using Volo.Abp.Threading;
using Volo.Abp.Uow;
namespace EShopOnAbp.CatalogService
{
@ -59,9 +61,23 @@ namespace EShopOnAbp.CatalogService
.AllowCredentials();
});
});
Configure<AbpAspNetCoreMvcOptions>(options =>
{
options.ConventionalControllers.Create(typeof(CatalogServiceApplicationModule).Assembly, opts =>
{
opts.RootPath = "catalog";
opts.RemoteServiceName = "Catalog";
});
});
Configure<AbpUnitOfWorkDefaultOptions>(options =>
{
//Standalone MongoDB servers don't support transactions
options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled;
});
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
var app = context.GetApplicationBuilder();

13
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationChecker.cs

@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations;
using Volo.Abp.EventBus.Distributed;
@ -9,11 +10,14 @@ namespace EShopOnAbp.CatalogService.DbMigrations
{
public class CatalogServiceDatabaseMigrationChecker : PendingMongoDbMigrationsChecker<CatalogServiceMongoDbContext>
{
private readonly ProductServiceDataSeeder _productServiceDataSeeder;
public CatalogServiceDatabaseMigrationChecker(
IUnitOfWorkManager unitOfWorkManager,
IServiceProvider serviceProvider,
ICurrentTenant currentTenant,
IDistributedEventBus distributedEventBus)
IDistributedEventBus distributedEventBus,
ProductServiceDataSeeder productServiceDataSeeder)
: base(
unitOfWorkManager,
serviceProvider,
@ -21,6 +25,13 @@ namespace EShopOnAbp.CatalogService.DbMigrations
distributedEventBus,
CatalogServiceDbProperties.ConnectionStringName)
{
_productServiceDataSeeder = productServiceDataSeeder;
}
public override async Task CheckAsync()
{
await base.CheckAsync();
await _productServiceDataSeeder.SeedAsync();
}
}
}

3
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/CatalogServiceDatabaseMigrationEventHandler.cs

@ -1,5 +1,4 @@
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations;
using System;
using System;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.MongoDB;
using EShopOnAbp.Shared.Hosting.Microservices.DbMigrations.MongoDb;

110
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/DbMigrations/ProductServiceDataSeeder.cs

@ -0,0 +1,110 @@
using System;
using System.Threading.Tasks;
using EShopOnAbp.CatalogService.Products;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.Uow;
namespace EShopOnAbp.CatalogService.DbMigrations
{
public class ProductServiceDataSeeder : ITransientDependency
{
private readonly ProductManager _productManager;
private readonly IRepository<Product, Guid> _productRepository;
public ProductServiceDataSeeder(
IRepository<Product, Guid> productRepository,
ProductManager productManager)
{
_productRepository = productRepository;
_productManager = productManager;
}
[UnitOfWork]
public virtual async Task SeedAsync()
{
await AddProductsAsync();
}
private async Task AddProductsAsync()
{
if (await _productRepository.GetCountAsync() > 0)
{
return;
}
await _productManager.CreateAsync(
"ABP04918",
"Lego Star Wars - 75059 Sandcrawler UCS",
999,
42,
"lego.jpg"
);
await _productManager.CreateAsync(
"ABP23849",
"Nikon AF-S 50mm f/1.8 G Lens",
1499,
56,
"nikon.jpg"
);
await _productManager.CreateAsync(
"ABP82731",
"Beats Solo3 Wireless On-Ear Headphone",
97,
20,
"beats.jpg"
);
await _productManager.CreateAsync(
"ABP12322",
"Rampage Sn-Rw2 Gamer Headphone",
654,
42,
"rampage.jpg"
);
await _productManager.CreateAsync(
"ABP00291",
"Asus Transformer Book T300CHI-FH011H",
1249,
3,
"asus.jpg"
);
await _productManager.CreateAsync(
"ABP02918",
"OKI C332DN Dublex + Network A4 Laser Printer",
215,
6,
"oki.jpg"
);
await _productManager.CreateAsync(
"ABP11121",
"Bluecat Rd810 Mini Led",
449,
13,
"bluecat.jpg"
);
await _productManager.CreateAsync(
"ABP44432",
"Sunny 55\" TV 4K Ultra HD Curved Smart Led TV",
2249,
1,
"sunny.jpg"
);
await _productManager.CreateAsync(
"ABP37182",
"Sony Playstation 4 Slim 500 GB (PAL)",
699,
120,
"playstation.jpg"
);
}
}
}

2
services/catalog/src/EShopOnAbp.CatalogService.HttpApi.Host/appsettings.json

@ -18,7 +18,7 @@
},
"AllowedHosts": "*",
"ConnectionStrings": {
"CatalogService": "User ID=root;Password=root;Host=localhost;Port=5432;Database=EShopOnAbp_Catalog;Pooling=false;",
"CatalogService": "mongodb://localhost:27017/EShopOnAbp_Catalog",
"AdministrationService": "User ID=root;Password=root;Host=localhost;Port=5432;Database=EShopOnAbp_Administration;Pooling=false;"
},
"StringEncryption": {

8
services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContext.cs

@ -1,4 +1,6 @@
using Volo.Abp.Data;
using EShopOnAbp.CatalogService.Products;
using MongoDB.Driver;
using Volo.Abp.Data;
using Volo.Abp.MongoDB;
namespace EShopOnAbp.CatalogService.MongoDB
@ -6,9 +8,7 @@ namespace EShopOnAbp.CatalogService.MongoDB
[ConnectionStringName(CatalogServiceDbProperties.ConnectionStringName)]
public class CatalogServiceMongoDbContext : AbpMongoDbContext, ICatalogServiceMongoDbContext
{
/* Add mongo collections here. Example:
* public IMongoCollection<Question> Questions => Collection<Question>();
*/
public IMongoCollection<Product> Questions => Collection<Product>();
protected override void CreateModel(IMongoModelBuilder modelBuilder)
{

8
services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbContextExtensions.cs

@ -1,4 +1,5 @@
using Volo.Abp;
using EShopOnAbp.CatalogService.Products;
using Volo.Abp;
using Volo.Abp.MongoDB;
namespace EShopOnAbp.CatalogService.MongoDB
@ -9,6 +10,11 @@ namespace EShopOnAbp.CatalogService.MongoDB
this IMongoModelBuilder builder)
{
Check.NotNull(builder, nameof(builder));
builder.Entity<Product>(x =>
{
x.CollectionName = "Products";
});
}
}
}

1
services/catalog/src/EShopOnAbp.CatalogService.MongoDB/MongoDB/CatalogServiceMongoDbModule.cs

@ -14,6 +14,7 @@ namespace EShopOnAbp.CatalogService.MongoDB
{
context.Services.AddMongoDbContext<CatalogServiceMongoDbContext>(options =>
{
options.AddDefaultRepositories();
/* Add custom repositories here. Example:
* options.AddRepository<Question, MongoQuestionRepository>();
*/

3
shared/EShopOnAbp.Shared.Localization/Localization/EShopOnAbp/en.json

@ -2,6 +2,7 @@
"culture": "en",
"texts": {
"Menu:Home": "Home",
"Login": "Login"
"Login": "Login",
"Catalog": "Catalog"
}
}

Loading…
Cancel
Save