-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
646e4b7
commit 8ab0ea9
Showing
39 changed files
with
252 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using Newtonsoft.Json; | ||
|
||
namespace Magicodes.Wx.Enterprise.Sdk.Apis | ||
{ | ||
/// <summary> | ||
/// API请求结果 | ||
/// {"errcode":40164,"errmsg":"invalid ip 218.76.8.29 ipv6 ::ffff:218.76.8.29, not in whitelist rid: 60122c35-705c3134-51b45a3d"} | ||
/// </summary> | ||
public class ApiResultBase | ||
{ | ||
/// <summary> | ||
/// 返回码 | ||
/// </summary> | ||
[JsonProperty("errcode")] | ||
public virtual ReturnCodes ReturnCode { get; set; } | ||
|
||
/// <summary> | ||
/// 错误消息 | ||
/// </summary> | ||
[JsonProperty("errmsg")] | ||
public virtual string Message { get; set; } | ||
|
||
/// <summary> | ||
/// 是否为成功返回 | ||
/// </summary> | ||
/// <returns></returns> | ||
public virtual bool IsSuccess() | ||
{ | ||
return ReturnCode == ReturnCodes.请求成功; | ||
} | ||
|
||
/// <summary> | ||
/// 获取友好提示 | ||
/// </summary> | ||
/// <returns></returns> | ||
public virtual string GetFriendlyMessage() | ||
{ | ||
return ReturnCode.ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
namespace Magicodes.Wx.Enterprise.Sdk.Apis | ||
{ | ||
/// <summary> | ||
/// 公众号返回码(JSON) | ||
/// </summary> | ||
public enum ReturnCodes | ||
{ | ||
系统繁忙此时请开发者稍候再试 = -1, | ||
请求成功 = 0, | ||
|
||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
src/Magicodes.Wx.Enterprise.Sdk/Apis/Token/Dtos/TokenApiResult.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Newtonsoft.Json; | ||
using System; | ||
|
||
namespace Magicodes.Wx.Enterprise.Sdk.Apis.Token.Dtos | ||
{ | ||
public class TokenApiResult : ApiResultBase | ||
{ | ||
/// <summary> | ||
/// 获取到的凭证 | ||
/// </summary> | ||
[JsonProperty("access_token")] | ||
public string AccessToken { get; set; } | ||
|
||
/// <summary> | ||
/// 凭证有效时间,单位:秒。正常情况下为7200秒(2小时) | ||
/// </summary> | ||
[JsonProperty("expires_in")] | ||
internal int Expires { get; set; } | ||
|
||
/// <summary> | ||
/// 凭证过期时间 | ||
/// </summary> | ||
public DateTime ExpiresTime { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Magicodes.Wx.Enterprise.Sdk.Apis.Token.Dtos; | ||
using Magicodes.Wx.Sdk.Core; | ||
using System.ComponentModel.DataAnnotations; | ||
using System.Threading.Tasks; | ||
using WebApiClientCore.Attributes; | ||
|
||
namespace Magicodes.Wx.Enterprise.Sdk.Apis.Token | ||
{ | ||
[HttpHost("https://qyapi.weixin.qq.com/cgi-bin/")] | ||
public interface ITokenApi : IWxApiBase | ||
{ | ||
/// <summary> | ||
/// 获取access_token | ||
/// </summary> | ||
/// <param name="corpid">企业ID,获取方式参考:术语说明-corpid</param> | ||
/// <param name="corpsecret">应用的凭证密钥,获取方式参考:术语说明-secret</param> | ||
/// <returns></returns> | ||
[HttpGet("gettoken")] | ||
Task<TokenApiResult> GetAsync([Required] string corpid, [Required] string corpsecret); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/Magicodes.Wx.Enterprise.Sdk/Magicodes.Wx.Enterprise.Sdk.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<Import Project="..\..\common.props"></Import> | ||
<PropertyGroup> | ||
<TargetFramework>netstandard2.1</TargetFramework> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\Magicodes.Wx.Sdk.Core\Magicodes.Wx.Sdk.Core.csproj" /> | ||
</ItemGroup> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Magicodes.Wx.PublicAccount.Sdk/Apis/CustomerService/IKfAccountApi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
src/Magicodes.Wx.PublicAccount.Sdk/Apis/Message/ITemplateApi.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.Extensions.Configuration; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace Magicodes.Wx.PublicAccount.Sdk.Config | ||
{ | ||
public class ConfigHelper | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
public static WxPublicAccountOption GetWeChatOptionsByConfiguration(IConfiguration configuration) | ||
{ | ||
IConfigurationSection wechatConfig = configuration.GetSection(WxConsts.WX_CONFIG_SECTION_KEY); | ||
if (wechatConfig == null) return null; | ||
return new WxPublicAccountOption() | ||
{ | ||
AppId = wechatConfig["AppId"], | ||
AppSecret = wechatConfig["AppSecret"], | ||
Token = wechatConfig["Token"], | ||
WeiXinAccount = wechatConfig["WeiXinAccount"], | ||
}; | ||
} | ||
} | ||
} |
Oops, something went wrong.