From 6e9ec1c080f1a2d8ea3f2e923acd807487ada271 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期五, 21 十一月 2025 16:40:02 +0800
Subject: [PATCH] feat:开发
---
ApiTools.Application/WxUtils/Commands/WxmpSubscribMessageCommandHandler.cs | 66 +++++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/ApiTools.Application/WxUtils/Commands/WxmpSubscribMessageCommandHandler.cs b/ApiTools.Application/WxUtils/Commands/WxmpSubscribMessageCommandHandler.cs
new file mode 100644
index 0000000..3e600b2
--- /dev/null
+++ b/ApiTools.Application/WxUtils/Commands/WxmpSubscribMessageCommandHandler.cs
@@ -0,0 +1,66 @@
+锘縰sing Aop.Api.Domain;
+using ApiTools.Core;
+using log4net.Core;
+using MediatR;
+using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace ApiTools.Application
+{
+ public class WxmpSubscribMessageCommandHandler(
+ ILogger<WxmpSubscribMessageCommandHandler> logger,
+ WxmpUtils utils,
+ IHttpContextAccessor httpContextAccessor
+ ) :
+ IRequestHandler<SendWxmpSubscribMessageCommand, Guid>,
+ IRequestHandler<WxmpSubscribMessageNotifyCommand, bool>
+ {
+ private readonly ILogger<WxmpSubscribMessageCommandHandler> logger = logger;
+ private readonly WxmpUtils utils = utils;
+ private readonly IHttpContextAccessor httpContextAccessor = httpContextAccessor;
+
+ /// <summary>
+ /// 寰俊灏忕▼搴忓彂閫佽闃呮秷鎭�
+ /// </summary>
+ /// <param name="request"></param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ public async Task<Guid> Handle(SendWxmpSubscribMessageCommand request, CancellationToken cancellationToken)
+ {
+ await utils.WxmpSendSubscribMessage(new WxmpSendSubscribMessageRequest
+ {
+ Data = request.Data,
+ TemplateId = request.TemplateId,
+ Page = request.Page,
+ WxmpCode = request.WxmpCode,
+ Touser = request.Touser,
+ });
+ return Guid.Empty;
+ }
+
+ /// <summary>
+ /// 寰俊灏忕▼搴忚闃呮秷鎭�氱煡
+ /// </summary>
+ /// <param name="request"></param>
+ /// <param name="cancellationToken"></param>
+ /// <returns></returns>
+ public async Task<bool> Handle(WxmpSubscribMessageNotifyCommand request, CancellationToken cancellationToken)
+ {
+ var req = httpContextAccessor.HttpContext.Request;
+ logger.LogInformation($"寰俊灏忕▼搴忚闃呮秷鎭�氱煡query锛歿req.QueryString.Value}");
+
+ req.EnableBuffering();
+ req.Body.Position = 0;
+ using var reader = new StreamReader(req.Body, Encoding.UTF8, leaveOpen: true);
+ var body = await reader.ReadToEndAsync();
+ logger.LogInformation($"寰俊灏忕▼搴忚闃呮秷鎭�氱煡body锛歿body}");
+ req.Body.Position = 0;
+ return true;
+ }
+ }
+}
--
Gitblit v1.9.1