Skip to content

Commit 67795a0

Browse files
committed
添加标签管理支持
1 parent 3db7c17 commit 67795a0

File tree

13 files changed

+388
-56
lines changed

13 files changed

+388
-56
lines changed

weixin-java-enterprise/src/main/java/me/chanjar/weixin/common/bean/result/WxError.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@
1010
*/
1111
public class WxError {
1212

13-
protected int errorCode;
13+
private int errorCode;
1414

15-
protected String errorMsg;
15+
private String errorMsg;
1616

17+
private String json;
18+
1719
public int getErrorCode() {
1820
return errorCode;
1921
}
@@ -31,12 +33,14 @@ public void setErrorMsg(String errorMsg) {
3133
}
3234

3335
public static WxError fromJson(String json) {
34-
return WxCpGsonBuilder.create().fromJson(json, WxError.class);
36+
WxError error = WxCpGsonBuilder.create().fromJson(json, WxError.class);
37+
error.json = json;
38+
return error;
3539
}
3640

3741
@Override
3842
public String toString() {
39-
return "微信错误 errcode=" + errorCode + ", errmsg=" + errorMsg;
43+
return "微信错误 errcode=" + errorCode + ", errmsg=" + errorMsg + "\njson:" + json;
4044
}
4145

4246
}

weixin-java-enterprise/src/main/java/me/chanjar/weixin/enterprise/api/WxCpConsts.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class WxCpConsts {
1818
public static final String XML_MSG_EVENT = "event";
1919

2020
///////////////////////
21-
// 客服消息的消息类型
21+
// 消息的消息类型
2222
///////////////////////
2323
public static final String CUSTOM_MSG_TEXT = "text";
2424
public static final String CUSTOM_MSG_IMAGE = "image";

weixin-java-enterprise/src/main/java/me/chanjar/weixin/enterprise/api/WxCpService.java

Lines changed: 120 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,17 @@
1515
* 微信API的Service
1616
*/
1717
public interface WxCpService {
18-
18+
1919
/**
2020
* <pre>
2121
* 验证推送过来的消息的正确性
2222
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=验证消息真实性
2323
* </pre>
24+
*
2425
* @param msgSignature
2526
* @param timestamp
2627
* @param nonce
27-
* @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息
28+
* @param data 微信传输过来的数据,有可能是echoStr,有可能是xml消息
2829
* @return
2930
*/
3031
public boolean checkSignature(String msgSignature, String timestamp, String nonce, String data);
@@ -34,6 +35,7 @@ public interface WxCpService {
3435
* 用在二次验证的时候
3536
* 企业在员工验证成功后,调用本方法告诉企业号平台该员工关注成功。
3637
* </pre>
38+
*
3739
* @param userId
3840
*/
3941
public void userAuthenticated(String userId) throws WxErrorException;
@@ -42,90 +44,93 @@ public interface WxCpService {
4244
* <pre>
4345
* 获取access_token,本方法线程安全
4446
* 且在多线程同时刷新时只刷新一次,避免超出2000次/日的调用次数上限
45-
*
4647
* 另:本service的所有方法都会在access_token过期是调用此方法
47-
*
4848
* 程序员在非必要情况下尽量不要主动调用此方法
49-
5049
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=获取access_token
5150
* </pre>
51+
*
5252
* @throws me.chanjar.weixin.enterprise.exception.WxErrorException
5353
*/
5454
public void accessTokenRefresh() throws WxErrorException;
55-
55+
5656
/**
5757
* <pre>
5858
* 上传多媒体文件
59-
*
6059
* 上传的多媒体文件有格式和大小限制,如下:
6160
* 图片(image): 1M,支持JPG格式
6261
* 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式
6362
* 视频(video):10MB,支持MP4格式
6463
* 缩略图(thumb):64KB,支持JPG格式
65-
*
6664
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
6765
* </pre>
68-
* @param mediaType 媒体类型, 请看{@link WxCpConsts}
69-
* @param fileType 文件类型,请看{@link WxCpConsts}
70-
* @param inputStream 输入流
66+
*
67+
* @param mediaType 媒体类型, 请看{@link WxCpConsts}
68+
* @param fileType 文件类型,请看{@link WxCpConsts}
69+
* @param inputStream 输入流
7170
* @throws WxErrorException
7271
*/
73-
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream) throws WxErrorException, IOException;
72+
public WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream inputStream)
73+
throws WxErrorException, IOException;
7474

7575
/**
76-
* @see #mediaUpload(String, String, InputStream)
7776
* @param mediaType
7877
* @param file
7978
* @throws WxErrorException
79+
* @see #mediaUpload(String, String, InputStream)
8080
*/
8181
public WxMediaUploadResult mediaUpload(String mediaType, File file) throws WxErrorException;
82-
82+
8383
/**
8484
* <pre>
8585
* 下载多媒体文件
8686
* 根据微信文档,视频文件下载不了,会返回null
8787
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
8888
* </pre>
89-
* @params media_id
89+
*
9090
* @return 保存到本地的临时文件
9191
* @throws WxErrorException
92+
* @params media_id
9293
*/
9394
public File mediaDownload(String media_id) throws WxErrorException;
94-
95+
9596
/**
9697
* <pre>
97-
* 发送客服消息
98-
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=发送客服消息
98+
* 发送消息
99+
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=发送消息
99100
* </pre>
101+
*
100102
* @param message
101103
* @throws WxErrorException
102104
*/
103105
public void messageSend(WxCpMessage message) throws WxErrorException;
104-
106+
105107
/**
106108
* <pre>
107109
* 自定义菜单创建接口
108110
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口
109111
* </pre>
112+
*
110113
* @param menu
111114
* @throws WxErrorException
112115
*/
113116
public void menuCreate(WxCpMenu menu) throws WxErrorException;
114-
117+
115118
/**
116119
* <pre>
117120
* 自定义菜单删除接口
118121
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口
119122
* </pre>
123+
*
120124
* @throws WxErrorException
121125
*/
122126
public void menuDelete() throws WxErrorException;
123-
127+
124128
/**
125129
* <pre>
126130
* 自定义菜单查询接口
127131
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口
128132
* </pre>
133+
*
129134
* @return
130135
* @throws WxErrorException
131136
*/
@@ -137,64 +142,147 @@ public interface WxCpService {
137142
* 最多支持创建500个部门
138143
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
139144
* </pre>
145+
*
140146
* @param depart 部门
141147
* @return 部门id
142148
* @throws WxErrorException
143149
*/
144150
public Integer departCreate(WxCpDepart depart) throws WxErrorException;
145-
151+
146152
/**
147153
* <pre>
148154
* 部门管理接口 - 查询所有部门
149155
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
150156
* </pre>
157+
*
151158
* @return
152159
* @throws WxErrorException
153160
*/
154161
public List<WxCpDepart> departGet() throws WxErrorException;
155-
162+
156163
/**
157164
* <pre>
158165
* 部门管理接口 - 修改部门名
159166
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
160-
*
161167
* 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
162168
* </pre>
163-
* @param group 要更新的group,group的id,name必须设置
169+
*
170+
* @param group 要更新的group,group的id,name必须设置
164171
* @throws WxErrorException
165172
*/
166173
public void departUpdate(WxCpDepart group) throws WxErrorException;
167174

168175
/**
169176
* <pre>
170177
* 部门管理接口 - 删除部门
171-
*
172178
* </pre>
179+
*
173180
* @param departId
174181
* @throws WxErrorException
175182
*/
176183
public void departDelete(Integer departId) throws WxErrorException;
177184

185+
/**
186+
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98
187+
*
188+
* @param departId 必填。部门id
189+
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
190+
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
191+
* @return
192+
* @throws WxErrorException
193+
*/
194+
public List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
195+
196+
/**
197+
* 新建用户
198+
*
199+
* @param user
200+
* @throws WxErrorException
201+
*/
178202
public void userCreate(WxCpUser user) throws WxErrorException;
179203

204+
/**
205+
* 更新用户
206+
*
207+
* @param user
208+
* @throws WxErrorException
209+
*/
180210
public void userUpdate(WxCpUser user) throws WxErrorException;
181211

212+
/**
213+
* 删除用户
214+
*
215+
* @param userid
216+
* @throws WxErrorException
217+
*/
182218
public void userDelete(String userid) throws WxErrorException;
183219

220+
/**
221+
* 获取用户
222+
*
223+
* @param userid
224+
* @return
225+
* @throws WxErrorException
226+
*/
184227
public WxCpUser userGet(String userid) throws WxErrorException;
185228

186229
/**
187-
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E8.8E.B7.E5.8F.96.E9.83.A8.E9.97.A8.E6.88.90.E5.91.98
188-
* @param departId 必填。部门id
189-
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
190-
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
230+
* 创建标签
231+
*
232+
* @param tagName
191233
* @return
192-
* @throws WxErrorException
193234
*/
194-
public List<WxCpUser> userGetByDepart(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
235+
public String tagCreate(String tagName) throws WxErrorException;
236+
237+
/**
238+
* 更新标签
239+
*
240+
* @param tagId
241+
* @param tagName
242+
*/
243+
public void tagUpdate(String tagId, String tagName) throws WxErrorException;
244+
245+
/**
246+
* 删除标签
247+
*
248+
* @param tagId
249+
*/
250+
public void tagDelete(String tagId) throws WxErrorException;
251+
252+
/**
253+
* 获得标签列表
254+
*
255+
* @return
256+
*/
257+
public List<WxCpTag> tagGet() throws WxErrorException;
258+
259+
/**
260+
* 获取标签成员
261+
*
262+
* @param tagId
263+
* @return
264+
*/
265+
public List<WxCpUser> tagGetUsers(String tagId) throws WxErrorException;
266+
267+
/**
268+
* 增加标签成员
269+
*
270+
* @param tagId
271+
* @param userIds
272+
*/
273+
public void tagAddUsers(String tagId, List<String> userIds) throws WxErrorException;
274+
275+
/**
276+
* 移除标签成员
277+
*
278+
* @param tagId
279+
* @param userIds
280+
*/
281+
public void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException;
195282

196283
/**
197284
* 注入 {@link WxCpConfigStorage} 的实现
285+
*
198286
* @param wxConfigProvider
199287
*/
200288
public void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider);

0 commit comments

Comments
 (0)