11/**
22 * 微信公众号 API 类型定义
33 *
4- * 与后端微信 API 对应的 TypeScript 类型
4+ * 根据后端 wechatapi.rs 定义的 TypeScript 类型
55 */
66
77// ==================== 粉丝相关 ====================
88
9- /** 微信用户信息 */
9+ /** 微信用户信息 (对应后端 get_user_info / batch_get_user_info 响应) */
1010export interface WechatUser {
11+ subscribe ?: number ;
1112 openid : string ;
13+ language ?: string ;
14+ subscribe_time ?: number ;
15+ unionid ?: string ;
16+ remark ?: string ;
17+ groupid ?: number ;
18+ tagid_list ?: number [ ] ;
19+ subscribe_scene ?: string ;
20+ qr_scene ?: number ;
21+ qr_scene_str ?: string ;
22+ // 以下字段在 batch_get_user_info 时可能包含
1223 nickname ?: string ;
1324 sex ?: number ;
1425 city ?: string ;
1526 province ?: string ;
1627 country ?: string ;
1728 headimgurl ?: string ;
18- subscribe_time ?: number ;
19- remark ?: string ;
20- tagid_list ?: number [ ] ;
2129}
2230
23- /** 粉丝列表响应 */
31+ /** 粉丝列表响应 (对应后端 get_user_list) */
2432export interface UserListResponse {
2533 total : number ;
2634 count : number ;
27- data : { openid : string [ ] } ;
28- next_openid : string ;
35+ data : string [ ] | null ; // 后端返回 openid 数组
36+ next_openid : string | null ;
37+ }
38+
39+ /** 批量获取用户信息请求 */
40+ export interface BatchGetUserInfoRequest {
41+ openids : string [ ] ;
42+ lang ?: string ;
2943}
3044
3145/** 批量获取用户信息响应 */
@@ -58,39 +72,53 @@ export interface CreateTagRequest {
5872 name : string ;
5973}
6074
61- /** 创建标签响应 */
75+ /** 创建标签响应 (后端直接返回 { id, name }) */
6276export interface CreateTagResponse {
63- tag : WechatTag ;
77+ id : number ;
78+ name : string ;
6479}
6580
6681/** 更新标签请求 */
6782export interface UpdateTagRequest {
68- id : number ;
83+ id : number ; // 后端是 i32
6984 name : string ;
7085}
7186
7287/** 删除标签请求 */
7388export interface DeleteTagRequest {
74- id : number ;
89+ id : number ; // 后端是 i32
90+ }
91+
92+ /** 获取标签下用户响应 */
93+ export interface GetUsersByTagResponse {
94+ count : number ;
95+ data : string [ ] | null ; // openid 数组
96+ next_openid : string | null ;
7597}
7698
7799/** 批量打标签请求 */
78100export interface BatchTagUsersRequest {
79- openid_list : string [ ] ;
80- tagid : number ;
101+ openids : string [ ] ;
102+ tag_id : number ; // 后端是 i32
103+ }
104+
105+ /** 获取用户标签响应 */
106+ export interface GetUserTagsResponse {
107+ tagid_list : number [ ] ;
81108}
82109
83110// ==================== 菜单相关 ====================
84111
85- /** 菜单按钮 */
112+ /** 菜单按钮 (对应后端 MenuButtonRequest) */
86113export interface MenuButton {
87114 type ?: string ;
88115 name : string ;
89116 key ?: string ;
90117 url ?: string ;
118+ media_id ?: string ;
119+ article_id ?: string ;
91120 appid ?: string ;
92121 pagepath ?: string ;
93- media_id ?: string ;
94122 sub_button ?: MenuButton [ ] ;
95123}
96124
@@ -99,9 +127,49 @@ export interface Menu {
99127 button : MenuButton [ ] ;
100128}
101129
130+ /** 个性化菜单匹配规则 */
131+ export interface MatchRule {
132+ tag_id ?: string ;
133+ client_platform_type ?: string ;
134+ }
135+
136+ /** 个性化菜单 */
137+ export interface ConditionalMenu {
138+ button : MenuButton [ ] ;
139+ matchrule : MatchRule ;
140+ menuid ?: number ;
141+ }
142+
102143/** 获取菜单响应 */
103144export interface GetMenuResponse {
104145 menu ?: Menu ;
146+ conditionalmenu ?: ConditionalMenu [ ] ;
147+ }
148+
149+ /** 创建菜单请求 (注意后端字段是 buttons 不是 button) */
150+ export interface CreateMenuRequest {
151+ buttons : MenuButton [ ] ;
152+ }
153+
154+ /** 创建个性化菜单请求 */
155+ export interface CreateConditionalMenuRequest {
156+ buttons : MenuButton [ ] ;
157+ matchrule : MatchRule ;
158+ }
159+
160+ /** 创建个性化菜单响应 */
161+ export interface CreateConditionalMenuResponse {
162+ menuid : number ;
163+ }
164+
165+ /** 删除个性化菜单请求 */
166+ export interface DeleteConditionalMenuRequest {
167+ menuid : number ;
168+ }
169+
170+ /** 测试个性化菜单匹配请求 */
171+ export interface TryMatchMenuRequest {
172+ user_id : string ;
105173}
106174
107175// ==================== 模板消息相关 ====================
@@ -129,8 +197,30 @@ export interface IndustryClass {
129197
130198/** 行业信息 */
131199export interface Industry {
132- primary_industry ?: IndustryClass ;
133- secondary_industry ?: IndustryClass ;
200+ primary_industry : IndustryClass ;
201+ secondary_industry : IndustryClass ;
202+ }
203+
204+ /** 设置行业请求 */
205+ export interface SetIndustryRequest {
206+ industry_id1 : string ;
207+ industry_id2 : string ;
208+ }
209+
210+ /** 添加模板请求 */
211+ export interface AddTemplateRequest {
212+ template_id_short : string ;
213+ }
214+
215+ /** 添加模板响应 */
216+ export interface AddTemplateResponse {
217+ template_id : string ;
218+ }
219+
220+ /** 小程序跳转配置 */
221+ export interface MiniProgram {
222+ appid : string ;
223+ pagepath ?: string ;
134224}
135225
136226/** 模板数据项 */
@@ -141,14 +231,18 @@ export interface TemplateDataItem {
141231
142232/** 发送模板消息请求 */
143233export interface SendTemplateRequest {
144- template_id : string ;
145234 touser : string ;
235+ template_id : string ;
146236 url ?: string ;
147- miniprogram ?: {
148- appid : string ;
149- pagepath ?: string ;
150- } ;
237+ miniprogram ?: MiniProgram ;
151238 data : Record < string , TemplateDataItem > ;
239+ client_msg_id ?: string ;
240+ }
241+
242+ /** 发送模板消息响应 */
243+ export interface SendTemplateResponse {
244+ success : boolean ;
245+ msgid : number ;
152246}
153247
154248/** 删除模板请求 */
@@ -199,23 +293,47 @@ export interface SendNewsRequest {
199293 articles : NewsArticle [ ] ;
200294}
201295
296+ /** 设置输入状态请求 */
297+ export interface SetTypingRequest {
298+ touser : string ;
299+ typing : boolean ;
300+ }
301+
202302// ==================== 二维码相关 ====================
203303
304+ /** 二维码类型 */
305+ export type QrCodeAction = 'temporary' | 'permanent' | 'temporary_str' | 'permanent_str' ;
306+
204307/** 创建二维码请求 */
205308export interface CreateQrcodeRequest {
206- action_name : 'QR_SCENE' | 'QR_STR_SCENE' | 'QR_LIMIT_SCENE' | 'QR_LIMIT_STR_SCENE' ;
309+ scene_id ?: number ;
310+ scene_str ?: string ;
311+ action : QrCodeAction ;
207312 expire_seconds ?: number ;
208- action_info : {
209- scene : {
210- scene_id ?: number ;
211- scene_str ?: string ;
212- } ;
213- } ;
214313}
215314
216315/** 创建二维码响应 */
217316export interface CreateQrcodeResponse {
218317 ticket : string ;
219318 expire_seconds ?: number ;
220319 url : string ;
320+ qrcode_url : string ;
321+ }
322+
323+ /** 长链接转短链接请求 */
324+ export interface CreateShortUrlRequest {
325+ long_url : string ;
326+ }
327+
328+ /** 长链接转短链接响应 */
329+ export interface CreateShortUrlResponse {
330+ short_url : string ;
331+ }
332+
333+ // ==================== 通用响应 ====================
334+
335+ /** 成功响应 */
336+ export interface WechatSuccessResponse {
337+ success : boolean ;
338+ message : string ;
221339}
0 commit comments