Skip to content

Commit 6b1b7f1

Browse files
committed
重构企业号代码
1 parent a90628c commit 6b1b7f1

26 files changed

+706
-271
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
import me.chanjar.weixin.common.exception.WxErrorException;
4+
import me.chanjar.weixin.cp.bean.WxCpDepart;
5+
6+
import java.util.List;
7+
8+
/**
9+
* <pre>
10+
* 部门管理接口
11+
* Created by BinaryWang on 2017/6/24.
12+
* </pre>
13+
*
14+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
15+
*/
16+
public interface WxCpDepartmentService {
17+
18+
/**
19+
* <pre>
20+
* 部门管理接口 - 创建部门
21+
* 最多支持创建500个部门
22+
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
23+
* </pre>
24+
*
25+
* @param depart 部门
26+
* @return 部门id
27+
*/
28+
Integer create(WxCpDepart depart) throws WxErrorException;
29+
30+
/**
31+
* <pre>
32+
* 部门管理接口 - 查询所有部门
33+
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
34+
* </pre>
35+
*/
36+
List<WxCpDepart> listAll() throws WxErrorException;
37+
38+
/**
39+
* <pre>
40+
* 部门管理接口 - 修改部门名
41+
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
42+
* 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
43+
* </pre>
44+
*
45+
* @param group 要更新的group,group的id,name必须设置
46+
*/
47+
void update(WxCpDepart group) throws WxErrorException;
48+
49+
/**
50+
* <pre>
51+
* 部门管理接口 - 删除部门
52+
* </pre>
53+
*
54+
* @param departId 部门id
55+
*/
56+
void delete(Integer departId) throws WxErrorException;
57+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
/**
4+
* <pre>
5+
* Created by BinaryWang on 2017/6/24.
6+
* </pre>
7+
*
8+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
9+
*/
10+
public interface WxCpMediaService {
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
/**
4+
* <pre>
5+
* Created by BinaryWang on 2017/6/24.
6+
* </pre>
7+
*
8+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
9+
*/
10+
public interface WxCpMenuService {
11+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
/**
4+
* <pre>
5+
* Created by BinaryWang on 2017/6/24.
6+
* </pre>
7+
*
8+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
9+
*/
10+
public interface WxCpOauth2Service {
11+
}

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

Lines changed: 65 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
1010
import me.chanjar.weixin.common.util.http.RequestExecutor;
1111
import me.chanjar.weixin.cp.bean.*;
12+
import me.chanjar.weixin.cp.config.WxCpConfigStorage;
1213

1314
import java.io.File;
1415
import java.io.IOException;
@@ -33,16 +34,6 @@ public interface WxCpService {
3334
*/
3435
boolean checkSignature(String msgSignature, String timestamp, String nonce, String data);
3536

36-
/**
37-
* <pre>
38-
* 用在二次验证的时候
39-
* 企业在员工验证成功后,调用本方法告诉企业号平台该员工关注成功。
40-
* </pre>
41-
*
42-
* @param userId 用户id
43-
*/
44-
void userAuthenticated(String userId) throws WxErrorException;
45-
4637
/**
4738
* 获取access_token, 不强制刷新access_token
4839
*
@@ -218,109 +209,77 @@ WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream i
218209
WxMenu menuGet(Integer agentId) throws WxErrorException;
219210

220211
/**
221-
* <pre>
222-
* 部门管理接口 - 创建部门
223-
* 最多支持创建500个部门
224-
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
225-
* </pre>
226-
*
227-
* @param depart 部门
228-
* @return 部门id
212+
* @deprecated 请使用 {@link WxCpDepartmentService#create(WxCpDepart depart) }
229213
*/
214+
@Deprecated
230215
Integer departCreate(WxCpDepart depart) throws WxErrorException;
231216

232217
/**
233-
* <pre>
234-
* 部门管理接口 - 查询所有部门
235-
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
236-
* </pre>
237-
*/
238-
List<WxCpDepart> departGet() throws WxErrorException;
239-
240-
/**
241-
* <pre>
242-
* 部门管理接口 - 修改部门名
243-
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=部门管理接口
244-
* 如果id为0(未部门),1(黑名单),2(星标组),或者不存在的id,微信会返回系统繁忙的错误
245-
* </pre>
246-
*
247-
* @param group 要更新的group,group的id,name必须设置
218+
* @deprecated 请使用 {@link WxCpDepartmentService#update(WxCpDepart group) }
248219
*/
220+
@Deprecated
249221
void departUpdate(WxCpDepart group) throws WxErrorException;
250222

251223
/**
252-
* <pre>
253-
* 部门管理接口 - 删除部门
254-
* </pre>
255-
*
256-
* @param departId 部门id
224+
* @deprecated 请使用 {@link WxCpDepartmentService#delete(Integer departId) }
257225
*/
226+
@Deprecated
258227
void departDelete(Integer departId) throws WxErrorException;
259228

260229
/**
261-
* <pre>
262-
* 获取部门成员(详情)
263-
*
264-
* 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.28.E8.AF.A6.E6.83.85.29
265-
* </pre>
266-
*
267-
* @param departId 必填。部门id
268-
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
269-
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
230+
* @deprecated 请使用 {@link WxCpDepartmentService#listAll() }
270231
*/
271-
List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
232+
@Deprecated
233+
List<WxCpDepart> departGet() throws WxErrorException;
272234

273235
/**
274-
* <pre>
275-
* 获取部门成员
276-
*
277-
* 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
278-
* </pre>
279-
*
280-
* @param departId 必填。部门id
281-
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
282-
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
236+
* @deprecated 请使用 {@link WxCpUserService#authenticate(String userId) }
283237
*/
284-
List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
238+
@Deprecated
239+
void userAuthenticated(String userId) throws WxErrorException;
285240

286241
/**
287-
* 新建用户
288-
*
289-
* @param user 用户对象
242+
* @deprecated 请使用 {@link WxCpUserService#create(WxCpUser user) }
290243
*/
244+
@Deprecated
291245
void userCreate(WxCpUser user) throws WxErrorException;
292246

293247
/**
294-
* 更新用户
295-
*
296-
* @param user 用户对象
248+
* @deprecated 请使用 {@link WxCpUserService#update(WxCpUser user)}
297249
*/
250+
@Deprecated
298251
void userUpdate(WxCpUser user) throws WxErrorException;
299252

300253
/**
301-
* 删除用户
302-
*
303-
* @param userid 用户id
254+
* @deprecated 请使用 {@link WxCpUserService#delete(String... userids) }
304255
*/
256+
@Deprecated
305257
void userDelete(String userid) throws WxErrorException;
306258

307259
/**
308-
* <pre>
309-
* 批量删除成员
310-
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98
311-
* </pre>
312-
*
313-
* @param userids 员工UserID列表。对应管理端的帐号
260+
* @deprecated 请使用 {@link WxCpUserService#delete(String[] userids) }
314261
*/
262+
@Deprecated
315263
void userDelete(String[] userids) throws WxErrorException;
316264

317265
/**
318-
* 获取用户
319-
*
320-
* @param userid 用户id
266+
* @deprecated 请使用 {@link WxCpUserService#getById(String userid) }
321267
*/
268+
@Deprecated
322269
WxCpUser userGet(String userid) throws WxErrorException;
323270

271+
/**
272+
* @deprecated 请使用 {@link WxCpUserService#listByDepartment(Integer departId, Boolean fetchChild, Integer status) }
273+
*/
274+
@Deprecated
275+
List<WxCpUser> userList(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
276+
277+
/**
278+
* @deprecated 请使用 {@link WxCpUserService#listSimpleByDepartment(Integer departId, Boolean fetchChild, Integer status) }
279+
*/
280+
@Deprecated
281+
List<WxCpUser> departGetUsers(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
282+
324283
/**
325284
* 创建标签
326285
*
@@ -560,4 +519,34 @@ WxMediaUploadResult mediaUpload(String mediaType, String fileType, InputStream i
560519
* @param wxConfigProvider 配置对象
561520
*/
562521
void setWxCpConfigStorage(WxCpConfigStorage wxConfigProvider);
522+
523+
/**
524+
* 获取部门相关接口的服务类对象
525+
*/
526+
WxCpDepartmentService getDepartmentService();
527+
528+
/**
529+
* 获取媒体相关接口的服务类对象
530+
*/
531+
WxCpMediaService getMediaService();
532+
533+
/**
534+
* 获取菜单相关接口的服务类对象
535+
*/
536+
WxCpMenuService getMenuService();
537+
538+
/**
539+
* 获取Oauth2相关接口的服务类对象
540+
*/
541+
WxCpOauth2Service getOauth2Service();
542+
543+
/**
544+
* 获取标签相关接口的服务类对象
545+
*/
546+
WxCpTagService getTagService();
547+
548+
/**
549+
* 获取用户相关接口的服务类对象
550+
*/
551+
WxCpUserService getUserService();
563552
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
/**
4+
* <pre>
5+
* Created by BinaryWang on 2017/6/24.
6+
* </pre>
7+
*
8+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
9+
*/
10+
public interface WxCpTagService {
11+
}
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
package me.chanjar.weixin.cp.api;
2+
3+
import me.chanjar.weixin.common.exception.WxErrorException;
4+
import me.chanjar.weixin.cp.bean.WxCpUser;
5+
6+
import java.util.List;
7+
8+
/**
9+
* <pre>
10+
* 用户管理接口
11+
* Created by BinaryWang on 2017/6/24.
12+
* </pre>
13+
*
14+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
15+
*/
16+
public interface WxCpUserService {
17+
/**
18+
* <pre>
19+
* 用在二次验证的时候
20+
* 企业在员工验证成功后,调用本方法告诉企业号平台该员工关注成功。
21+
* </pre>
22+
*
23+
* @param userId 用户id
24+
*/
25+
void authenticate(String userId) throws WxErrorException;
26+
27+
/**
28+
* <pre>
29+
* 获取部门成员(详情)
30+
*
31+
* 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.28.E8.AF.A6.E6.83.85.29
32+
* </pre>
33+
*
34+
* @param departId 必填。部门id
35+
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
36+
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
37+
*/
38+
List<WxCpUser> listByDepartment(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
39+
40+
/**
41+
* <pre>
42+
* 获取部门成员
43+
*
44+
* 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
45+
* </pre>
46+
*
47+
* @param departId 必填。部门id
48+
* @param fetchChild 非必填。1/0:是否递归获取子部门下面的成员
49+
* @param status 非必填。0获取全部员工,1获取已关注成员列表,2获取禁用成员列表,4获取未关注成员列表。status可叠加
50+
*/
51+
List<WxCpUser> listSimpleByDepartment(Integer departId, Boolean fetchChild, Integer status) throws WxErrorException;
52+
53+
/**
54+
* 新建用户
55+
*
56+
* @param user 用户对象
57+
*/
58+
void create(WxCpUser user) throws WxErrorException;
59+
60+
/**
61+
* 更新用户
62+
*
63+
* @param user 用户对象
64+
*/
65+
void update(WxCpUser user) throws WxErrorException;
66+
67+
/**
68+
* <pre>
69+
* 删除用户/批量删除成员
70+
* http://qydev.weixin.qq.com/wiki/index.php?title=管理成员#.E6.89.B9.E9.87.8F.E5.88.A0.E9.99.A4.E6.88.90.E5.91.98
71+
* </pre>
72+
*
73+
* @param userIds 员工UserID列表。对应管理端的帐号
74+
*/
75+
void delete(String... userIds) throws WxErrorException;
76+
77+
/**
78+
* 获取用户
79+
*
80+
* @param userid 用户id
81+
*/
82+
WxCpUser getById(String userid) throws WxErrorException;
83+
}

0 commit comments

Comments
 (0)