From a59e5d99a77fcb152e6fe49df78f69cb5fd6c5a0 Mon Sep 17 00:00:00 2001 From: sunpengfei <i@angelzzz.com> Date: 星期二, 19 八月 2025 15:58:10 +0800 Subject: [PATCH] feat:开发 --- FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs | 62 +++++++++++++++++++++++++++++++ 1 files changed, 62 insertions(+), 0 deletions(-) diff --git a/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs b/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs new file mode 100644 index 0000000..17662b7 --- /dev/null +++ b/FlexJobApi.CommonServer.Application/LogRecords/Commands/ResendResourceCommandHandler.cs @@ -0,0 +1,62 @@ +锘縰sing FlexJobApi.Core; +using FlexJobApi.Core.Entities.Common; +using Furion.DatabaseAccessor; +using Furion.FriendlyException; +using MediatR; +using Microsoft.EntityFrameworkCore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace FlexJobApi.CommonServer.Application +{ + /// <summary> + /// 閲嶆柊鍙戦�佽祫婧� + /// </summary> + public class ResendResourceCommandHandler( + IRepository<ResourceLog, LogDbContextLocator> repResourceLog, + IRepository<Resource> repResource, + ResourceHttpUtils resourceHttpUtils + ) : + IRequestHandler<ResendResourceCommand, string> + { + private readonly IRepository<ResourceLog, LogDbContextLocator> repResourceLog = repResourceLog; + private readonly IRepository<Resource> repResource = repResource; + private readonly ResourceHttpUtils resourceHttpUtils = resourceHttpUtils; + + /// <summary> + /// 閲嶆柊鍙戦�佽祫婧� + /// </summary> + /// <param name="request"></param> + /// <param name="cancellationToken"></param> + /// <returns></returns> + public async Task<string> Handle(ResendResourceCommand request, CancellationToken cancellationToken) + { + var log = await repResourceLog.AsQueryable().AsNoTracking() + .Where(it => it.Id == request.Id) + .Select(it => new + { + it.Method, + it.Path, + it.Request, + it.CreatedUserId + }) + .FirstOrDefaultAsync(); + if (log == null) throw Oops.Oh(EnumErrorCodeType.s404, "鏃ュ織"); + var resource = await repResource.AsQueryable().AsNoTracking() + .Where(it => it.Method == log.Method && it.Route == log.Path) + .FirstOrDefaultAsync(); + var paramters = log.Request + .JsonTo(new + { + request = new object() + }) + .request + .ToJson(); + var result = await resourceHttpUtils.SendHttpAsync(resource, paramters); + return result; + } + } +} -- Gitblit v1.9.1