//删除 public virtual async Task <Unit> Handle(RemoveCommand <TEntity> message, CancellationToken cancellationToken) { if (!message.IsValid()) { await NotifyValidationErrorsAsync(message); return(await Task.FromResult(new Unit())); } if (await ExistsByIdAsync(message.Id)) { await CommandRepository.RemoveAsync(message.Id); } else { //通过领域事件发布 错误 通知 await Bus.RaiseEvent(new DomainNotification(DomainHandlerType.Remove, DomainNotificationType.Error, "", $"{typeof(TEntity).Name} 不存在该Id {message.Id}!", message.Id)); return(await Task.FromResult(new Unit())); } if (await CommitAsync()) { //通过领域事件发布 通知 await Bus.RaiseEvent(new DomainNotification(DomainHandlerType.Remove, DomainNotificationType.Success, "", $"{typeof(TEntity).Name} 删除成功", message.Id)); } return(await Task.FromResult(new Unit())); }