You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
3 months ago
|
using Kean.Domain.Task.Commands;
|
||
|
using Kean.Domain.Task.Events;
|
||
|
using Kean.Domain.Task.Repositories;
|
||
|
using System.Threading;
|
||
|
|
||
|
namespace Kean.Domain.Task.EventHandlers
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 任务取消命令成功时,处理后续
|
||
|
/// </summary>
|
||
|
public sealed class CancelSuccessEventHandler_Follow : EventHandler<CancelSuccessEvent>
|
||
|
{
|
||
|
private readonly ICommandBus _commandBus; // 命令总线
|
||
|
private readonly ITaskRepository _taskRepository; // 任务仓库
|
||
|
|
||
|
/// <summary>
|
||
|
/// 依赖注入
|
||
|
/// </summary>
|
||
|
public CancelSuccessEventHandler_Follow(
|
||
|
ICommandBus commandBus,
|
||
|
ITaskRepository taskRepository)
|
||
|
{
|
||
|
_commandBus = commandBus;
|
||
|
_taskRepository = taskRepository;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 处理程序
|
||
|
/// </summary>
|
||
|
public override async System.Threading.Tasks.Task Handle(CancelSuccessEvent @event, CancellationToken cancellationToken)
|
||
|
{
|
||
|
foreach (var item in await _taskRepository.GetCancelFollows(@event.Id))
|
||
|
{
|
||
|
await _commandBus.Execute(new CallDeleteCommand { Id = item.Id }, cancellationToken);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|