From 312ebed2d86858e4fb57ec09679244e9b806b57f Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期五, 28 十一月 2025 17:56:10 +0800
Subject: [PATCH] feat:开发
---
ApiTools.Core/Utils/WxmpUtils/WxmpUtils.cs | 50 +++++++++++++++++++++++++++++---------------------
1 files changed, 29 insertions(+), 21 deletions(-)
diff --git a/ApiTools.Core/Utils/WxmpUtils/WxmpUtils.cs b/ApiTools.Core/Utils/WxmpUtils/WxmpUtils.cs
index cb686c5..39321b6 100644
--- a/ApiTools.Core/Utils/WxmpUtils/WxmpUtils.cs
+++ b/ApiTools.Core/Utils/WxmpUtils/WxmpUtils.cs
@@ -130,19 +130,39 @@
}
/// <summary>
- /// 璇ユ帴鍙g敤浜庡彂閫佽闃呮秷鎭�
+ /// 鏌ヨ璁㈤槄娑堟伅妯℃澘
/// </summary>
/// <param name="command"></param>
/// <returns></returns>
- public async Task<string> WxSend(SendRequest command)
+ public async Task<GetWxmpSubscribMessageTemplatesResponse> GetWxmpSubscribMessageTemplate(GetWxmpSubscribMessageTemplatesRequest command)
{
var option = options.Value.Items.FirstOrDefault(it => it.Code == command.WxmpCode);
if (option == null || option.AppId.IsNull() || option.AppSecret.IsNull())
- throw Oops.Oh(EnumErrorCodeType.s400, "鑾峰彇灏忕▼搴忕爜澶辫触锛岀己澶遍厤缃細WxmpOptions");
+ throw Oops.Oh(EnumErrorCodeType.s400, "鍙戦�佽闃呮秷鎭け璐ワ紝缂哄け閰嶇疆锛歐xmpOptions");
+ var accessToken = await GetAccessToken(command.WxmpCode);
+ var jsonContent = JsonConvert.SerializeObject(command, new JsonSerializerSettings
+ {
+ NullValueHandling = NullValueHandling.Ignore
+ });
+ var response = await httpRemoteService.GetAsAsync<GetWxmpSubscribMessageTemplatesResponse>(
+ "https://api.weixin.qq.com/wxaapi/newtmpl/gettemplate",
+ builder => builder.WithQueryParameter("access_token", accessToken));
+ return response;
+ }
+
+ /// <summary>
+ /// 鍙戦�佽闃呮秷鎭�
+ /// </summary>
+ /// <param name="command"></param>
+ /// <returns></returns>
+ public async Task WxmpSendSubscribMessage(WxmpSendSubscribMessageRequest command)
+ {
+ var option = options.Value.Items.FirstOrDefault(it => it.Code == command.WxmpCode);
+ if (option == null || option.AppId.IsNull() || option.AppSecret.IsNull())
+ throw Oops.Oh(EnumErrorCodeType.s400, "鍙戦�佽闃呮秷鎭け璐ワ紝缂哄け閰嶇疆锛歐xmpOptions");
command.EnvVersion = option.EnvVersion;
var accessToken = await GetAccessToken(command.WxmpCode);
- var request = command.Adapt<SendRequest>();
- var jsonContent = JsonConvert.SerializeObject(request, new JsonSerializerSettings
+ var jsonContent = JsonConvert.SerializeObject(command, new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
});
@@ -151,22 +171,10 @@
.WithQueryParameter("access_token", accessToken)
.SetJsonContent(jsonContent));
response.EnsureSuccessStatusCode();
- //var a = response.Content.Headers.ContentType.ToString();
- //application/json; encoding=utf-8
- //if (response.Content.Headers.ContentType.ToString() == "application/json; charset=UTF-8")
- if (response.Content.Headers.ContentType.ToString() == "application/json; encoding=utf-8")
- {
- var jsonResult = await response.Content.ReadAsStringAsync();
- //var callback = jsonResult.JsonTo<SendResponse>();
- //if (callback == null || callback.ErrorCode != 0)
- //throw Oops.Oh(EnumErrorCodeType.s510, $"鑾峰彇灏忕▼搴忕爜澶辫触锛歿callback.errmsg}锛岃鑱旂郴绠$悊鍛�");
- return jsonResult;
- }
- //var stream = await response.Content.ReadAsStreamAsync();
- //var result = AliyunOSSUtils.Upload(command, stream, command.OssFileName);
- return "";
+ var jsonResult = await response.Content.ReadAsStringAsync();
+ var callback = jsonResult.JsonTo<WxmpSendSubscribMessageResponse>();
+ if (callback == null || callback.ErrorCode != 0)
+ throw Oops.Oh(EnumErrorCodeType.s510, $"鍙戦�佽闃呮秷鎭け璐ワ細{callback.ErrorMessage}锛岃鑱旂郴绠$悊鍛�");
}
-
-
}
}
--
Gitblit v1.9.1