Skip to content

Commit

Permalink
Add Notify3Async and Notify4Async actions
Browse files Browse the repository at this point in the history
  • Loading branch information
gdlcf88 committed Jul 13, 2023
1 parent 1a69db9 commit cc31aef
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 7 deletions.
8 changes: 4 additions & 4 deletions docs/WeChatOfficial.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ var result = await customMenuService.DeleteCustomMenuAsync();
在您调用服务,或处理微信请求的事件通知回调时,若提供的 `appId` 与 Setting 中的默认值可能不同,则您需要手动实现 `IAbpWeChatOptionsProvider<TOptions>`,若使用 EasyAbp 封装的[微信管理模块](https://github.com/EasyAbp/WeChatManagement),则您无需再手动实现。

本模块提供的用于微信服务器通讯的 HTTP API 接口,也支持多应用和多租户,您需要使用合适的替代路由:
* `/wechat/verify`
* `/wechat/verify/tenant-id/{tenantId}`
* `/wechat/verify/app-id/{appId}`
* `/wechat/verify/tenant-id/{tenantId}/app-id/{appId}`
* `/wechat/notify`
* `/wechat/notify/tenant-id/{tenantId}`
* `/wechat/notify/app-id/{appId}`
* `/wechat/notify/tenant-id/{tenantId}/app-id/{appId}`
* `/wechat/redirect-url`
* `/wechat/redirect-url/tenant-id/{tenantId}`
* `/wechat/redirect-url/app-id/{appId}`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ public virtual async Task<ActionResult> GetJsSdkConfigParametersAsync(
/// 微信应用事件通知接口,开发人员需要实现 <see cref="IWeChatOfficialAppEventHandler"/> 处理器来处理回调请求。
/// </summary>
[HttpPost]
[Route("notify/app-id/{appId}")]
public virtual async Task<ActionResult> NotifyAsync([CanBeNull] string tenantId, [NotNull] string appId)
[Route("notify")]
public virtual async Task<ActionResult> NotifyAsync([CanBeNull] string tenantId, [CanBeNull] string appId)
{
using var changeTenant = CurrentTenant.Change(tenantId.IsNullOrWhiteSpace() ? null : Guid.Parse(tenantId!));

Expand Down Expand Up @@ -220,12 +220,34 @@ public virtual async Task<ActionResult> NotifyAsync([CanBeNull] string tenantId,
/// 见 <see cref="NotifyAsync"/>
/// </summary>
[HttpPost]
[Route("notify/tenant-id/{tenantId}/app-id/{appId}")]
[Route("notify/tenant-id/{tenantId}")]
public virtual Task<ActionResult> Notify2Async([CanBeNull] string tenantId, [NotNull] string appId)
{
return NotifyAsync(tenantId, appId);
}

/// <summary>
/// 本方法是为了避免多 Route 导致 ABP ApiDescription 报 Warning。
/// 见 <see cref="NotifyAsync"/>
/// </summary>
[HttpPost]
[Route("notify/app-id/{appId}")]
public virtual Task<ActionResult> Notify3Async([CanBeNull] string tenantId, [NotNull] string appId)
{
return NotifyAsync(tenantId, appId);
}

/// <summary>
/// 本方法是为了避免多 Route 导致 ABP ApiDescription 报 Warning。
/// 见 <see cref="NotifyAsync"/>
/// </summary>
[HttpPost]
[Route("notify/tenant-id/{tenantId}/app-id/{appId}")]
public virtual Task<ActionResult> Notify4Async([CanBeNull] string tenantId, [NotNull] string appId)
{
return NotifyAsync(tenantId, appId);
}

protected virtual async Task<WeChatOfficialEventRequestModel> CreateRequestModelAsync()
{
Request.EnableBuffering();
Expand Down

0 comments on commit cc31aef

Please sign in to comment.