Add PicBaseUrl with a replaced parameter
This commit is contained in:
parent
96c55b8682
commit
f0f88aee98
@ -29,7 +29,7 @@ services:
|
||||
- ASPNETCORE_ENVIRONMENT=Development
|
||||
- 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}
|
||||
- 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}
|
||||
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
|
||||
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
|
||||
@ -70,7 +70,7 @@ services:
|
||||
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
|
||||
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
|
||||
- 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}
|
||||
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY}
|
||||
ports:
|
||||
|
@ -34,7 +34,7 @@ services:
|
||||
- ASPNETCORE_ENVIRONMENT=Production
|
||||
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}
|
||||
- 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}
|
||||
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
|
||||
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
|
||||
@ -75,7 +75,7 @@ services:
|
||||
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
|
||||
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
|
||||
- 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}
|
||||
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY}
|
||||
ports:
|
||||
|
@ -232,13 +232,12 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
private List<CatalogItem> ChangeUriPlaceholder(List<CatalogItem> items)
|
||||
{
|
||||
var baseUri = _settings.PicBaseUrl;
|
||||
|
||||
|
||||
items.ForEach(catalogItem =>
|
||||
{
|
||||
catalogItem.PictureUri = _settings.AzureStorageEnabled
|
||||
? baseUri + catalogItem.PictureFileName
|
||||
: baseUri + catalogItem.Id;
|
||||
|
||||
: baseUri.Replace("[0]", catalogItem.Id.ToString());
|
||||
});
|
||||
|
||||
return items;
|
||||
|
@ -9,7 +9,6 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
{
|
||||
[Route("api/v1/[controller]")]
|
||||
public class PicController : Controller
|
||||
{
|
||||
private readonly IHostingEnvironment _env;
|
||||
@ -22,17 +21,18 @@ namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
|
||||
_catalogContext = catalogContext;
|
||||
}
|
||||
|
||||
[HttpGet("{id}")]
|
||||
[HttpGet]
|
||||
[Route("api/v1/catalog/items/{catalogItemId:int}/pic")]
|
||||
// GET: /<controller>/
|
||||
public async Task<IActionResult> GetImage(int id)
|
||||
public async Task<IActionResult> GetImage(int catalogItemId)
|
||||
{
|
||||
if (id <= 0)
|
||||
if (catalogItemId <= 0)
|
||||
{
|
||||
return BadRequest();
|
||||
}
|
||||
|
||||
var item = await _catalogContext.CatalogItems
|
||||
.SingleOrDefaultAsync(ci => ci.Id == id);
|
||||
.SingleOrDefaultAsync(ci => ci.Id == catalogItemId);
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"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,
|
||||
"Logging": {
|
||||
"IncludeScopes": false,
|
||||
|
@ -221,7 +221,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API.Controllers
|
||||
|
||||
return _settings.AzureStorageEnabled
|
||||
? baseUri + campaign.PictureName
|
||||
: baseUri + campaign.Id;
|
||||
: baseUri.Replace("[0]", campaign.Id.ToString());
|
||||
}
|
||||
}
|
||||
}
|
@ -5,12 +5,13 @@
|
||||
"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",
|
||||
"MongoDatabase": "MarketingDb",
|
||||
"IdentityUrl": "http://localhost:5105",
|
||||
"ExternalCatalogBaseUrl": "http://localhost:5110",
|
||||
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/",
|
||||
"AzureServiceBusEnabled": false,
|
||||
"SubscriptionClientName": "Marketing",
|
||||
"AzureStorageEnabled": false
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user