mirror of https://github.com/abpframework/abp.git
4 changed files with 9 additions and 51 deletions
@ -1,26 +1,24 @@ |
|||||
using System.Threading.Tasks; |
using System.Threading.Tasks; |
||||
|
using Volo.Abp.Caching; |
||||
using Volo.Abp.DependencyInjection; |
using Volo.Abp.DependencyInjection; |
||||
using Volo.Abp.Domain.Entities.Events; |
using Volo.Abp.Domain.Entities.Events; |
||||
using Volo.Abp.EventBus; |
using Volo.Abp.EventBus; |
||||
using Volo.Abp.EventBus.Distributed; |
using Volo.CmsKit.Public.Menus; |
||||
|
|
||||
namespace Volo.CmsKit.Menus |
namespace Volo.CmsKit.Menus |
||||
{ |
{ |
||||
public class MenuUpdatedHandler : ILocalEventHandler<EntityUpdatedEventData<Menu>>, ITransientDependency |
public class MenuUpdatedHandler : ILocalEventHandler<EntityUpdatedEventData<Menu>>, ITransientDependency |
||||
{ |
{ |
||||
public IDistributedEventBus EventBus { get; } |
protected IDistributedCache<MenuWithDetailsDto, MainMenuCacheKey> DistributedCache { get; } |
||||
|
|
||||
public MenuUpdatedHandler(IDistributedEventBus eventBus) |
public MenuUpdatedHandler(IDistributedCache<MenuWithDetailsDto, MainMenuCacheKey> distributedCache) |
||||
{ |
{ |
||||
EventBus = eventBus; |
DistributedCache = distributedCache; |
||||
} |
} |
||||
|
|
||||
public async Task HandleEventAsync(EntityUpdatedEventData<Menu> eventData) |
public async Task HandleEventAsync(EntityUpdatedEventData<Menu> eventData) |
||||
{ |
{ |
||||
await EventBus.PublishAsync(new MenuUpdatedEto |
await DistributedCache.RemoveAsync(new MainMenuCacheKey()); |
||||
{ |
|
||||
MenuId = eventData.Entity.Id |
|
||||
}); |
|
||||
} |
} |
||||
} |
} |
||||
} |
} |
||||
@ -1,12 +0,0 @@ |
|||||
using System; |
|
||||
using Volo.Abp.Domain.Entities.Events.Distributed; |
|
||||
using Volo.Abp.EventBus; |
|
||||
|
|
||||
namespace Volo.CmsKit.Menus |
|
||||
{ |
|
||||
[EventName("Volo.CmsKit.Menus.Updated")] |
|
||||
public class MenuUpdatedEto : EtoBase |
|
||||
{ |
|
||||
public Guid MenuId { get; set; } |
|
||||
} |
|
||||
} |
|
||||
@ -1,23 +0,0 @@ |
|||||
using System.Threading.Tasks; |
|
||||
using Volo.Abp.Caching; |
|
||||
using Volo.Abp.DependencyInjection; |
|
||||
using Volo.Abp.EventBus.Distributed; |
|
||||
using Volo.CmsKit.Menus; |
|
||||
|
|
||||
namespace Volo.CmsKit.Public.Menus |
|
||||
{ |
|
||||
public class MenuUpdatedHandler : IDistributedEventHandler<MenuUpdatedEto>, ITransientDependency |
|
||||
{ |
|
||||
protected IDistributedCache<MenuWithDetailsDto, MainMenuCacheKey> DistributedCache { get; } |
|
||||
|
|
||||
public MenuUpdatedHandler(IDistributedCache<MenuWithDetailsDto, MainMenuCacheKey> distributedCache) |
|
||||
{ |
|
||||
DistributedCache = distributedCache; |
|
||||
} |
|
||||
|
|
||||
public async Task HandleEventAsync(MenuUpdatedEto eventData) |
|
||||
{ |
|
||||
await DistributedCache.RemoveAsync(new MainMenuCacheKey()); |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
Loading…
Reference in new issue