Browse Source
Merge pull request #208 from EasyAbp/fix-state-bug
Fix a state bug in `InventoryActor`
pull/209/head
Super
4 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
2 deletions
-
plugins/Inventories/DaprActors/src/EasyAbp.EShop.Plugins.Inventories.DaprActors/EasyAbp/EShop/Plugins/Inventories/DaprActors/InventoryActor.cs
|
|
|
@ -2,6 +2,7 @@ using System; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Dapr; |
|
|
|
using Dapr.Actors.Runtime; |
|
|
|
using JetBrains.Annotations; |
|
|
|
|
|
|
|
namespace EasyAbp.EShop.Plugins.Inventories.DaprActors; |
|
|
|
|
|
|
|
@ -11,6 +12,9 @@ public class InventoryActor : Actor, IInventoryActor |
|
|
|
|
|
|
|
protected bool FlashSalesInventoryUpdated { get; set; } |
|
|
|
|
|
|
|
[CanBeNull] |
|
|
|
protected InventoryStateModel State { get; set; } |
|
|
|
|
|
|
|
public InventoryActor(ActorHost host) : base(host) |
|
|
|
{ |
|
|
|
} |
|
|
|
@ -20,8 +24,8 @@ public class InventoryActor : Actor, IInventoryActor |
|
|
|
await StateManager.TryAddStateAsync(InventoryStateName, new InventoryStateModel()); |
|
|
|
} |
|
|
|
|
|
|
|
public virtual Task<InventoryStateModel> GetInventoryStateAsync() => |
|
|
|
StateManager.GetStateAsync<InventoryStateModel>(InventoryStateName); |
|
|
|
public virtual async Task<InventoryStateModel> GetInventoryStateAsync() => |
|
|
|
State ??= await StateManager.GetStateAsync<InventoryStateModel>(InventoryStateName); |
|
|
|
|
|
|
|
public virtual async Task IncreaseInventoryAsync(int quantity, bool decreaseSold, bool isFlashSale) |
|
|
|
{ |
|
|
|
|