public async Task <R> Handle(IdentifiedCommand <T, R> request, CancellationToken cancellationToken) { if (await manager.ExistAsync(request.Id) || !await manager.CreateRequestForCommandAsync <T>(request.Id)) { return(await CreateResultForDuplicateRequestAsync(request)); } logger.LogDebug("---Crated Identitified Request Id : {Id}, CommandName: {CommandType}", request.Id, typeof(T)); return(await mediator.Send(request.Command)); }
protected virtual Task <R> CreateResultForDuplicateRequestAsync(IdentifiedCommand <T, R> request) { throw new InvalidCommandException("重复请求", "请求已经收到,正在处理中,请稍后再试."); }