| | |
| | | /// </summary> |
| | | public class ResendResourceCommandHandler( |
| | | IRepository<ResourceLog, LogDbContextLocator> repResourceLog, |
| | | IRepository<Resource> repResource, |
| | | ResourceHttpUtils resourceHttpUtils |
| | | IRepository<Resource> repResource |
| | | ) : |
| | | IRequestHandler<ResendResourceCommand, string> |
| | | { |
| | | private readonly IRepository<ResourceLog, LogDbContextLocator> repResourceLog = repResourceLog; |
| | | private readonly IRepository<Resource> repResource = repResource; |
| | | private readonly ResourceHttpUtils resourceHttpUtils = resourceHttpUtils; |
| | | |
| | | /// <summary> |
| | | /// 重新发送资源 |
| | |
| | | if (log == null) throw Oops.Oh(EnumErrorCodeType.s404, "日志"); |
| | | var resource = await repResource.AsQueryable().AsNoTracking() |
| | | .Where(it => it.Method == log.Method && it.Route == log.Path) |
| | | .Select(it => new |
| | | { |
| | | it.ServiceName, |
| | | it.Route, |
| | | it.Method |
| | | }) |
| | | .FirstOrDefaultAsync(); |
| | | if (resource == null) throw Oops.Oh(EnumErrorCodeType.s404, "资源"); |
| | | var paramters = log.Request |
| | | .JsonTo(new |
| | | { |
| | |
| | | }) |
| | | .request |
| | | .ToJson(); |
| | | var result = await resourceHttpUtils.SendHttpAsync(resource, paramters); |
| | | var result = await paramters.SendHttpAsync(resource.ServiceName, resource.Route, resource.Method); |
| | | return result; |
| | | } |
| | | } |