【优化】优化接口端新增加的几个controller的,增加httppost或者httpget的属性,防止swagger生成文档检测失败的情况。

This commit is contained in:
大灰灰
2023-01-01 22:37:51 +08:00
parent 614b05d8b1
commit a110ce1ccb
3 changed files with 9 additions and 7 deletions

View File

@@ -31,7 +31,7 @@ namespace CoreCms.Net.Web.Controllers.WeChat
/// <summary> /// <summary>
/// 微信公众号消息推送对接 /// 微信公众号消息推送对接
/// </summary> /// </summary>
public class WeChatOffiaccountNotifyController : Controller public class WeChatOffiaccountNotifyController : ControllerBase
{ {
private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly WeChatOptions _weChatOptions; private readonly WeChatOptions _weChatOptions;

View File

@@ -21,7 +21,7 @@ namespace CoreCms.Net.Web.Controllers.WeChat
/// <summary> /// <summary>
/// 微信公众号用户授权事件 /// 微信公众号用户授权事件
/// </summary> /// </summary>
public class WeChatOffiaccountOAuth2Controller : Controller public class WeChatOffiaccountOAuth2Controller : ControllerBase
{ {
//private readonly string _weChatAppId = AppSettingsConstVars.WeiXinAppId; //private readonly string _weChatAppId = AppSettingsConstVars.WeiXinAppId;
//private readonly string _weChatSecret = AppSettingsConstVars.WeiXinAppSecret; //private readonly string _weChatSecret = AppSettingsConstVars.WeiXinAppSecret;
@@ -48,6 +48,7 @@ namespace CoreCms.Net.Web.Controllers.WeChat
/// <param name="state"></param> /// <param name="state"></param>
/// <param name="bkUrl"></param> /// <param name="bkUrl"></param>
/// <returns></returns> /// <returns></returns>
[HttpGet]
public async Task<ActionResult> UserInfoCallback(string code, string state, string bkUrl) public async Task<ActionResult> UserInfoCallback(string code, string state, string bkUrl)
{ {
if (string.IsNullOrEmpty(code)) if (string.IsNullOrEmpty(code))

View File

@@ -21,7 +21,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// </summary> /// </summary>
[Route("api/[controller]/[action]")] [Route("api/[controller]/[action]")]
[ApiController] [ApiController]
public class WeChatOffiaccountController : Controller public class WeChatOffiaccountController : ControllerBase
{ {
private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory; private readonly IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
private readonly WeChatOptions _weChatOptions; private readonly WeChatOptions _weChatOptions;
@@ -55,7 +55,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var signatureStr = "jsapi_ticket=" + jsApiTicket + "&noncestr=" + nonceStr + "&timestamp=" + timestamp + "&url=" + url; var signatureStr = "jsapi_ticket=" + jsApiTicket + "&noncestr=" + nonceStr + "&timestamp=" + timestamp + "&url=" + url;
var signature = CoreCms.Net.Utility.Helper.CommonHelper.Sha1Signature(signatureStr); var signature = CoreCms.Net.Utility.Helper.CommonHelper.Sha1Signature(signatureStr);
return Json(new return new JsonResult(new
{ {
jsApiTicket, jsApiTicket,
appId = _weChatOptions.WeiXinAppId, appId = _weChatOptions.WeiXinAppId,
@@ -71,6 +71,7 @@ namespace CoreCms.Net.Web.WebApi.Controllers
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
[HttpPost]
public async Task<ActionResult> Send(TmpMsgModel model) public async Task<ActionResult> Send(TmpMsgModel model)
{ {
try try
@@ -144,12 +145,12 @@ namespace CoreCms.Net.Web.WebApi.Controllers
var response = await client.ExecuteCgibinMessageTemplateSendAsync(request, HttpContext.RequestAborted); var response = await client.ExecuteCgibinMessageTemplateSendAsync(request, HttpContext.RequestAborted);
return response.ErrorCode != (int)WeChatReturnCode.ReturnCode. return response.ErrorCode != (int)WeChatReturnCode.ReturnCode.
? Json(new { ResultCode = "1", Msg = "错误:" + response.ErrorMessage }) ? new JsonResult(new { ResultCode = "1", Msg = "错误:" + response.ErrorMessage })
: Json(new { ResultCode = "0", Msg = "已发送成功", Data = response.MessageId }); : new JsonResult(new { ResultCode = "0", Msg = "已发送成功", Data = response.MessageId });
} }
catch (Exception ex) catch (Exception ex)
{ {
return Json(new { ResultCode = "1", Msg = ex.ToString() }); return new JsonResult(new { ResultCode = "1", Msg = ex.ToString() });
} }
} }