Skip to content

Commit e8bce8f

Browse files
committed
创建个性化菜单
1 parent f64b163 commit e8bce8f

File tree

6 files changed

+66
-5
lines changed

6 files changed

+66
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@
131131
- [x] 查询接口(`GetAsync`)
132132
- [x] 删除接口(`DeleteAsync`)
133133
- [ ] 个性化菜单接口
134+
- [x] 创建个性化菜单(`AddConditionalAsync`)
135+
- [ ] 删除个性化菜单
136+
- [ ] 测试个性化菜单匹配结果
134137
- [ ] 获取自定义菜单配置
135138

136139
- [x] 订阅通知(`INewTmplApi`)

common.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>0.2.3</Version>
3+
<Version>0.2.4</Version>
44
</PropertyGroup>
55
<PropertyGroup>
66
<Authors>雪雁</Authors>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using Newtonsoft.Json;
2+
3+
namespace Magicodes.Wx.PublicAccount.Sdk.Apis.Menu
4+
{
5+
public class AddConditionalApiResult
6+
{
7+
[JsonProperty("menuid")]
8+
public string MenuId { get; set; }
9+
}
10+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Newtonsoft.Json;
2+
using System.Collections.Generic;
3+
4+
namespace Magicodes.Wx.PublicAccount.Sdk.Apis.Menu
5+
{
6+
public class AddConditionalInput
7+
{
8+
/// <summary>
9+
///一级菜单数组,个数应为1~3个
10+
/// </summary>
11+
[JsonProperty("button")]
12+
public List<MenuButtonBase> Button { get; set; }
13+
14+
/// <summary>
15+
/// 菜单匹配规则
16+
/// </summary>
17+
[JsonProperty("matchrule")]
18+
public MatchRule MatchRule { get; set; }
19+
}
20+
}

src/Magicodes.Wx.PublicAccount.Sdk/Apis/Menu/Dtos/MatchRule.cs

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,45 @@ namespace Magicodes.Wx.PublicAccount.Sdk.Apis.Menu
77
/// </summary>
88
public class MatchRule
99
{
10-
[JsonProperty(PropertyName = "group_id")]
11-
public string GroupId { get; set; }
10+
/// <summary>
11+
/// 用户标签的id,可通过用户标签管理接口获取
12+
/// </summary>
13+
[JsonProperty(PropertyName = "tag_id")]
14+
public string TagId { get; set; }
1215

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

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

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

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

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

46+
/// <summary>
47+
/// 语言信息,是用户在微信中设置的语言,具体请参考语言表: 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"
48+
/// </summary>
2849
[JsonProperty(PropertyName = "language")]
2950
public string Language { get; set; }
3051
}

src/Magicodes.Wx.PublicAccount.Sdk/Apis/Menu/IMenuApi.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,12 @@ public interface IMenuApi : IWxApiWithAccessTokenFilter
3333
/// <returns></returns>
3434
[HttpGet("delete")]
3535
Task<ApiResultBase> DeleteAsync();
36+
37+
/// <summary>
38+
/// 创建个性化菜单
39+
/// </summary>
40+
/// <returns></returns>
41+
[HttpPost("addconditional")]
42+
Task<AddConditionalApiResult> AddConditionalAsync([JsonNetContent(CharSet = "utf-8")] AddConditionalInput input);
3643
}
3744
}

0 commit comments

Comments
 (0)