Skip to content

Commit f0f88ae

Browse files
committed
Add PicBaseUrl with a replaced parameter
1 parent 96c55b8 commit f0f88ae

7 files changed

Lines changed: 16 additions & 16 deletions

File tree

docker-compose.override.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ services:
2929
- ASPNETCORE_ENVIRONMENT=Development
3030
- ASPNETCORE_URLS=http://0.0.0.0:80
3131
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word}
32-
- 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.
32+
- 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.
3333
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
3434
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
3535
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
@@ -70,7 +70,7 @@ services:
7070
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
7171
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
7272
- CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI}
73-
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/pic/}
73+
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/campaigns/[0]/pic/}
7474
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME}
7575
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY}
7676
ports:

docker-compose.prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ services:
3434
- ASPNETCORE_ENVIRONMENT=Production
3535
ASPNETCORE_URLS=http://0.0.0.0:80
3636
- ConnectionString=${ESHOP_AZURE_CATALOG_DB:-Server=sql.data;Database=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word}
37-
- 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.
37+
- PicBaseUrl=${ESHOP_AZURE_STORAGE_CATALOG} #Local: You need to open your local dev-machine firewall at range 5100-5110.
3838
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
3939
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_CATALOG_NAME}
4040
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_CATALOG_KEY}
@@ -75,7 +75,7 @@ services:
7575
- EventBusConnection=${ESHOP_AZURE_SERVICE_BUS:-rabbitmq}
7676
- identityUrl=http://identity.api #Local: You need to open your local dev-machine firewall at range 5100-5110.
7777
- CampaignDetailFunctionUri=${ESHOP_AZUREFUNC_CAMPAIGN_DETAILS_URI}
78-
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING:-http://localhost:5110/api/v1/pic/}
78+
- PicBaseUrl=${ESHOP_AZURE_STORAGE_MARKETING}
7979
- AzureStorageAccountName=${ESHOP_AZURE_STORAGE_MARKETING_NAME}
8080
- AzureStorageAccountKey=${ESHOP_AZURE_STORAGE_MARKETING_KEY}
8181
ports:

src/Services/Catalog/Catalog.API/Controllers/CatalogController.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,13 +232,12 @@ public async Task<IActionResult> DeleteProduct(int id)
232232
private List<CatalogItem> ChangeUriPlaceholder(List<CatalogItem> items)
233233
{
234234
var baseUri = _settings.PicBaseUrl;
235-
235+
236236
items.ForEach(catalogItem =>
237237
{
238238
catalogItem.PictureUri = _settings.AzureStorageEnabled
239239
? baseUri + catalogItem.PictureFileName
240-
: baseUri + catalogItem.Id;
241-
240+
: baseUri.Replace("[0]", catalogItem.Id.ToString());
242241
});
243242

244243
return items;

src/Services/Catalog/Catalog.API/Controllers/PicController.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
namespace Microsoft.eShopOnContainers.Services.Catalog.API.Controllers
1111
{
12-
[Route("api/v1/[controller]")]
1312
public class PicController : Controller
1413
{
1514
private readonly IHostingEnvironment _env;
@@ -22,17 +21,18 @@ public PicController(IHostingEnvironment env,
2221
_catalogContext = catalogContext;
2322
}
2423

25-
[HttpGet("{id}")]
24+
[HttpGet]
25+
[Route("api/v1/catalog/items/{catalogItemId:int}/pic")]
2626
// GET: /<controller>/
27-
public async Task<IActionResult> GetImage(int id)
27+
public async Task<IActionResult> GetImage(int catalogItemId)
2828
{
29-
if (id <= 0)
29+
if (catalogItemId <= 0)
3030
{
3131
return BadRequest();
3232
}
3333

3434
var item = await _catalogContext.CatalogItems
35-
.SingleOrDefaultAsync(ci => ci.Id == id);
35+
.SingleOrDefaultAsync(ci => ci.Id == catalogItemId);
3636

3737
if (item != null)
3838
{

src/Services/Catalog/Catalog.API/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.CatalogDb;User Id=sa;Password=Pass@word",
3-
"PicBaseUrl": "http://localhost:5101",
3+
"PicBaseUrl": "http://localhost:5101/api/v1/catalog/items/[0]/pic/",
44
"UseCustomizationData": false,
55
"Logging": {
66
"IncludeScopes": false,

src/Services/Marketing/Marketing.API/Controllers/CampaignsController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ private string GetUriPlaceholder(Campaign campaign)
221221

222222
return _settings.AzureStorageEnabled
223223
? baseUri + campaign.PictureName
224-
: baseUri + campaign.Id;
224+
: baseUri.Replace("[0]", campaign.Id.ToString());
225225
}
226226
}
227227
}

src/Services/Marketing/Marketing.API/appsettings.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@
55
"Default": "Warning"
66
}
77
},
8-
"ConnectionString": "127.0.0.1",
8+
"ConnectionString": "Server=tcp:127.0.0.1,5433;Initial Catalog=Microsoft.eShopOnContainers.Services.MarketingDb;User Id=sa;Password=Pass@word",
99
"MongoConnectionString": "mongodb://nosql.data",
1010
"MongoDatabase": "MarketingDb",
1111
"IdentityUrl": "http://localhost:5105",
12-
"ExternalCatalogBaseUrl": "http://localhost:5110",
12+
"PicBaseUrl": "http://localhost:5110/api/v1/campaigns/[0]/pic/",
1313
"AzureServiceBusEnabled": false,
1414
"SubscriptionClientName": "Marketing",
1515
"AzureStorageEnabled": false
16+
1617
}

0 commit comments

Comments
 (0)