Final fixes for demo

This commit is contained in:
2025-06-27 23:10:38 -06:00
parent 9effaf3b22
commit e191851982
4 changed files with 10 additions and 8 deletions

View File

@@ -45,7 +45,7 @@ namespace Core.Inventory.Domain.Contexts.Inventory.Request
[BsonElement("categoryId")] [BsonElement("categoryId")]
[BsonRepresentation(BsonType.String)] [BsonRepresentation(BsonType.String)]
[JsonPropertyName("categoryId")] [JsonPropertyName("categoryId")]
public Guid CategoryId { get; set; } public string CategoryId { get; set; } = string.Empty;
/// <summary> /// <summary>
/// Gets or sets the provider or vendor identifier of the item. /// Gets or sets the provider or vendor identifier of the item.
@@ -53,7 +53,7 @@ namespace Core.Inventory.Domain.Contexts.Inventory.Request
[BsonElement("providerId")] [BsonElement("providerId")]
[BsonRepresentation(BsonType.String)] [BsonRepresentation(BsonType.String)]
[JsonPropertyName("providerId")] [JsonPropertyName("providerId")]
public Guid ProviderId { get; set; } public string ProviderId { get; set; } = string.Empty;
/// <summary> /// <summary>
/// Gets or sets additional customizable attributes. /// Gets or sets additional customizable attributes.
@@ -61,6 +61,6 @@ namespace Core.Inventory.Domain.Contexts.Inventory.Request
/// </summary> /// </summary>
[BsonElement("attributes")] [BsonElement("attributes")]
[JsonPropertyName("attributes")] [JsonPropertyName("attributes")]
public Dictionary<string, object> Attributes { get; set; } = []; public Dictionary<string, string> Attributes { get; set; } = [];
} }
} }

View File

@@ -7,7 +7,7 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Adapters.Lib" Version="1.0.3" /> <PackageReference Include="Adapters.Lib" Version="1.0.8" />
<PackageReference Include="Core.Blueprint.Mongo" Version="1.0.0" /> <PackageReference Include="Core.Blueprint.Mongo" Version="1.0.0" />
<PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" /> <PackageReference Include="Core.Blueprint.Redis" Version="1.0.2" />
<PackageReference Include="Mapster" Version="7.4.0" /> <PackageReference Include="Mapster" Version="7.4.0" />

View File

@@ -22,6 +22,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private readonly CollectionRepository<FurnitureBase> repository; private readonly CollectionRepository<FurnitureBase> repository;
private readonly IRedisCacheProvider cacheProvider; private readonly IRedisCacheProvider cacheProvider;
private readonly CacheSettings cacheSettings; private readonly CacheSettings cacheSettings;
private const string getAllCache = "GetAllFurnitureBases";
public FurnitureBaseProvider( public FurnitureBaseProvider(
CollectionRepository<FurnitureBase> repository, CollectionRepository<FurnitureBase> repository,
@@ -72,7 +73,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
/// <returns>A list of <see cref="FurnitureBase"/>.</returns> /// <returns>A list of <see cref="FurnitureBase"/>.</returns>
public async ValueTask<IEnumerable<FurnitureBase>> GetAllAsync(CancellationToken cancellationToken) public async ValueTask<IEnumerable<FurnitureBase>> GetAllAsync(CancellationToken cancellationToken)
{ {
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, nameof(GetAllAsync)); var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllCache);
var cachedData = await cacheProvider.GetAsync<IEnumerable<FurnitureBase>>(cacheKey) ?? []; var cachedData = await cacheProvider.GetAsync<IEnumerable<FurnitureBase>>(cacheKey) ?? [];
if (cachedData.Any()) return cachedData; if (cachedData.Any()) return cachedData;
@@ -121,7 +122,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private async Task ResetCollectionCache() private async Task ResetCollectionCache()
{ {
//TODO: remove this method when necessary. //TODO: remove this method when necessary.
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllFurnitureBases"); var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllCache);
await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<FurnitureBase>(), null); await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<FurnitureBase>(), null);
} }

View File

@@ -23,6 +23,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private readonly CollectionRepository<FurnitureVariant> repository; private readonly CollectionRepository<FurnitureVariant> repository;
private readonly IRedisCacheProvider cacheProvider; private readonly IRedisCacheProvider cacheProvider;
private readonly CacheSettings cacheSettings; private readonly CacheSettings cacheSettings;
private const string getAllVariantsCache = "GetAllFurnitureVariants";
public FurnitureVariantProvider( public FurnitureVariantProvider(
CollectionRepository<FurnitureVariant> repository, CollectionRepository<FurnitureVariant> repository,
@@ -150,7 +151,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
/// <returns>A list of <see cref="FurnitureVariant"/>.</returns> /// <returns>A list of <see cref="FurnitureVariant"/>.</returns>
public async ValueTask<IEnumerable<FurnitureVariant>> GetAllAsync(CancellationToken cancellationToken) public async ValueTask<IEnumerable<FurnitureVariant>> GetAllAsync(CancellationToken cancellationToken)
{ {
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, nameof(GetAllAsync)); var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllVariantsCache);
var cachedData = await cacheProvider.GetAsync<IEnumerable<FurnitureVariant>>(cacheKey) ?? []; var cachedData = await cacheProvider.GetAsync<IEnumerable<FurnitureVariant>>(cacheKey) ?? [];
if (cachedData.Any()) return cachedData; if (cachedData.Any()) return cachedData;
@@ -167,7 +168,7 @@ namespace Core.Inventory.Provider.Providers.Inventory
private async Task ResetCollectionCache() private async Task ResetCollectionCache()
{ {
//TODO: remove this method when necessary. //TODO: remove this method when necessary.
var cacheKey = CacheKeyHelper.GenerateCacheKey(this, "GetAllFurnitureVariants"); var cacheKey = CacheKeyHelper.GenerateCacheKey(this, getAllVariantsCache);
await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<FurnitureVariant>(), null); await cacheProvider.SetAsync(cacheKey, Enumerable.Empty<FurnitureVariant>(), null);
} }