Skip to content

Commit

Permalink
创建个性化菜单
Browse files Browse the repository at this point in the history
  • Loading branch information
xl-wenqiang committed Apr 4, 2021
1 parent f64b163 commit e8bce8f
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 5 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,9 @@
- [x] 查询接口(`GetAsync`)
- [x] 删除接口(`DeleteAsync`)
- [ ] 个性化菜单接口
- [x] 创建个性化菜单(`AddConditionalAsync`)
- [ ] 删除个性化菜单
- [ ] 测试个性化菜单匹配结果
- [ ] 获取自定义菜单配置

- [x] 订阅通知(`INewTmplApi`)
Expand Down
2 changes: 1 addition & 1 deletion common.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<Version>0.2.3</Version>
<Version>0.2.4</Version>
</PropertyGroup>
<PropertyGroup>
<Authors>雪雁</Authors>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using Newtonsoft.Json;

namespace Magicodes.Wx.PublicAccount.Sdk.Apis.Menu
{
public class AddConditionalApiResult
{
[JsonProperty("menuid")]
public string MenuId { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using Newtonsoft.Json;
using System.Collections.Generic;

namespace Magicodes.Wx.PublicAccount.Sdk.Apis.Menu
{
public class AddConditionalInput
{
/// <summary>
///一级菜单数组,个数应为1~3个
/// </summary>
[JsonProperty("button")]
public List<MenuButtonBase> Button { get; set; }

/// <summary>
/// 菜单匹配规则
/// </summary>
[JsonProperty("matchrule")]
public MatchRule MatchRule { get; set; }
}
}
29 changes: 25 additions & 4 deletions src/Magicodes.Wx.PublicAccount.Sdk/Apis/Menu/Dtos/MatchRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,45 @@ namespace Magicodes.Wx.PublicAccount.Sdk.Apis.Menu
/// </summary>
public class MatchRule
{
[JsonProperty(PropertyName = "group_id")]
public string GroupId { get; set; }
/// <summary>
/// 用户标签的id,可通过用户标签管理接口获取
/// </summary>
[JsonProperty(PropertyName = "tag_id")]
public string TagId { get; set; }

[JsonProperty(PropertyName = "sex")]
public string Sex { get; set; }
/// <summary>
/// 性别:男(1)女(2),不填则不做匹配
/// </summary>
[JsonProperty(PropertyName = "sex", NullValueHandling = NullValueHandling.Ignore)]
public int? Sex { get; set; }

/// <summary>
/// 国家信息,是用户在微信中设置的地区,具体请参考地区信息表
/// </summary>
[JsonProperty(PropertyName = "country")]
public string Country { get; set; }

/// <summary>
/// 省份信息,是用户在微信中设置的地区,具体请参考地区信息表
/// </summary>
[JsonProperty(PropertyName = "province")]
public string Province { get; set; }

/// <summary>
/// 城市信息,是用户在微信中设置的地区,具体请参考地区信息表
/// </summary>
[JsonProperty(PropertyName = "city")]
public string City { get; set; }

/// <summary>
/// 客户端版本,当前只具体到系统型号:IOS(1), Android(2),Others(3),不填则不做匹配
/// </summary>
[JsonProperty(PropertyName = "client_platform_type")]
public string ClientPlatformType { get; set; }

/// <summary>
/// 语言信息,是用户在微信中设置的语言,具体请参考语言表: 1、简体中文 "zh_CN" 2、繁体中文TW "zh_TW" 3、繁体中文HK "zh_HK" 4、英文 "en" 5、印尼 "id" 6、马来 "ms" 7、西班牙 "es" 8、韩国 "ko" 9、意大利 "it" 10、日本 "ja" 11、波兰 "pl" 12、葡萄牙 "pt" 13、俄国 "ru" 14、泰文 "th" 15、越南 "vi" 16、阿拉伯语 "ar" 17、北印度 "hi" 18、希伯来 "he" 19、土耳其 "tr" 20、德语 "de" 21、法语 "fr"
/// </summary>
[JsonProperty(PropertyName = "language")]
public string Language { get; set; }
}
Expand Down
7 changes: 7 additions & 0 deletions src/Magicodes.Wx.PublicAccount.Sdk/Apis/Menu/IMenuApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,12 @@ public interface IMenuApi : IWxApiWithAccessTokenFilter
/// <returns></returns>
[HttpGet("delete")]
Task<ApiResultBase> DeleteAsync();

/// <summary>
/// 创建个性化菜单
/// </summary>
/// <returns></returns>
[HttpPost("addconditional")]
Task<AddConditionalApiResult> AddConditionalAsync([JsonNetContent(CharSet = "utf-8")] AddConditionalInput input);
}
}

0 comments on commit e8bce8f

Please sign in to comment.