Browse Source

Add PicBaseUrl with a replaced parameter

pull/241/head
Christian Arenas 7 years ago
parent
commit
f0f88aee98
7 changed files with 16 additions and 16 deletions
  1. +2
    -2
      docker-compose.override.yml
  2. +2
    -2
      docker-compose.prod.yml
  3. +2
    -3
      src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs
  4. +5
    -5
      src/Services/Catalog/Catalog.API/Controllers/PicController.cs
  5. +1
    -1
      src/Services/Catalog/Catalog.API/settings.json
  6. +1
    -1
      src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs
  7. +3
    -2
      src/Services/Marketing/Marketing.API/appsettings.json

+ 2
- 2
docker-compose.override.yml View File

@ -29,7 +29,7 @@ services:
- ASPNETCORE_ENVIRONMENT=Development - ASPNETCORE_ENVIRONMENT=Development
- ASPNETCORE_URLS=http://0.0.0.0:80 - ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word} - ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG:-http://localhost:5101/api/v1/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5110.
- PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG:-http://localhost:5101/api/v1/catalog/items/[0]/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5110.
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME} - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY} - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
@ -70,7 +70,7 @@ services:
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
- CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI} - CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/pic/}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/campaigns/[0]/pic/}
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME} - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME}
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY} - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY}
ports: ports:


+ 2
- 2
docker-compose.prod.yml View File

@ -34,7 +34,7 @@ services:
- ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_ENVIRONMENT=Production
ASPNETCORE_URLS=http://0.0.0.0:80 ASPNETCORE_URLS=http://0.0.0.0:80
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word} - ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG:-http://localhost:5101/api/v1/pic/} #Local: You need to open your local dev-machine firewall at range 5100-5110.
- PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG} #Local: You need to open your local dev-machine firewall at range 5100-5110.
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME} - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY} - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
@ -75,7 +75,7 @@ services:
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq} - EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110. - identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
- CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI} - CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/pic/}
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING}
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME} - AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME}
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY} - AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY}
ports: ports:


+ 2
- 3
src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs View File

@ -232,13 +232,12 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
private List<CatalogItem> ChangeUriPlaceholder(List<CatalogItem> items) private List<CatalogItem> ChangeUriPlaceholder(List<CatalogItem> items)
{ {
var baseUri = _settings.PicBaseUrl; var baseUri = _settings.PicBaseUrl;
items.ForEach(catalogItem => items.ForEach(catalogItem =>
{ {
catalogItem.PictureUri = _settings.AzureStorageEnabled catalogItem.PictureUri = _settings.AzureStorageEnabled
? baseUri + catalogItem.PictureFileName ? baseUri + catalogItem.PictureFileName
: baseUri + catalogItem.Id;
: baseUri.Replace("[0]", catalogItem.Id.ToString());
}); });
return items; return items;


+ 5
- 5
src/Services/Catalog/Catalog.API/Controllers/PicController.cs View File

@ -9,7 +9,6 @@ using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
{ {
[Route("api/v1/[controller]")]
public class PicController : Controller public class PicController : Controller
{ {
private readonly IHostingEnvironment _env; private readonly IHostingEnvironment _env;
@ -22,17 +21,18 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
_catalogContext = catalogContext; _catalogContext = catalogContext;
} }
[HttpGet("{id}")]
[HttpGet]
[Route("api/v1/catalog/items/{catalogItemId:int}/pic")]
// GET: /<controller>/ // GET: /<controller>/
public async Task<IActionResult> GetImage(int id)
public async Task<IActionResult> GetImage(int catalogItemId)
{ {
if (id <= 0)
if (catalogItemId <= 0)
{ {
return BadRequest(); return BadRequest();
} }
var item = await _catalogContext.CatalogItems var item = await _catalogContext.CatalogItems
.SingleOrDefaultAsync(ci => ci.Id == id);
.SingleOrDefaultAsync(ci => ci.Id == catalogItemId);
if (item != null) if (item != null)
{ {


+ 1
- 1
src/Services/Catalog/Catalog.API/settings.json View File

@ -1,6 +1,6 @@
{ {
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word", "ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word",
"PicBaseUrl": "http://localhost:5101",
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/",
"UseCustomizationData": false, "UseCustomizationData": false,
"Logging": { "Logging": {
"IncludeScopes": false, "IncludeScopes": false,


+ 1
- 1
src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs View File

@ -221,7 +221,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
return _settings.AzureStorageEnabled return _settings.AzureStorageEnabled
? baseUri + campaign.PictureName ? baseUri + campaign.PictureName
: baseUri + campaign.Id;
: baseUri.Replace("[0]", campaign.Id.ToString());
} }
} }
} }

+ 3
- 2
src/Services/Marketing/Marketing.API/appsettings.json View File

@ -5,12 +5,13 @@
"Default": "Warning" "Default": "Warning"
} }
}, },
"ConnectionString": "127.0.0.1",
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word",
"MongoConnectionString": "mongodb://nosql.data", "MongoConnectionString": "mongodb://nosql.data",
"MongoDatabase": "MarketingDb", "MongoDatabase": "MarketingDb",
"IdentityUrl": "http://localhost:5105", "IdentityUrl": "http://localhost:5105",
"ExternalCatalogBaseUrl": "http://localhost:5110",
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/",
"AzureServiceBusEnabled": false, "AzureServiceBusEnabled": false,
"SubscriptionClientName": "Marketing", "SubscriptionClientName": "Marketing",
"AzureStorageEnabled": false "AzureStorageEnabled": false
} }

Loading…
Cancel
Save