forked from Wechat-Group/WxJava
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
优化重构企业号相关代码,修复了升级企业微信后出现的菜单问题和用户管理的问题
- Loading branch information
1 parent
0f0f7bb
commit 9f4a7a7
Showing
29 changed files
with
1,022 additions
and
513 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMediaService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,57 @@ | ||
package me.chanjar.weixin.cp.api; | ||
|
||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; | ||
import me.chanjar.weixin.common.exception.WxErrorException; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
|
||
/** | ||
* <pre> | ||
* 媒体管理接口 | ||
* Created by BinaryWang on 2017/6/24. | ||
* </pre> | ||
* | ||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
*/ | ||
public interface WxCpMediaService { | ||
|
||
/** | ||
* <pre> | ||
* 上传多媒体文件 | ||
* 上传的多媒体文件有格式和大小限制,如下: | ||
* 图片(image): 1M,支持JPG格式 | ||
* 语音(voice):2M,播放长度不超过60s,支持AMR\MP3格式 | ||
* 视频(video):10MB,支持MP4格式 | ||
* 缩略图(thumb):64KB,支持JPG格式 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件 | ||
* </pre> | ||
* | ||
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts} | ||
* @param fileType 文件类型,请看{@link me.chanjar.weixin.common.api.WxConsts} | ||
* @param inputStream 输入流 | ||
*/ | ||
WxMediaUploadResult upload(String mediaType, String fileType, InputStream inputStream) | ||
throws WxErrorException, IOException; | ||
|
||
/** | ||
* @param mediaType 媒体类型 | ||
* @param file 文件对象 | ||
* @see #upload(String, String, InputStream) | ||
*/ | ||
WxMediaUploadResult upload(String mediaType, File file) throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 下载多媒体文件 | ||
* 根据微信文档,视频文件下载不了,会返回null | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件 | ||
* </pre> | ||
* | ||
* @param mediaId 媒体id | ||
* @return 保存到本地的临时文件 | ||
*/ | ||
File download(String mediaId) throws WxErrorException; | ||
|
||
} |
80 changes: 80 additions & 0 deletions
80
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpMenuService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,91 @@ | ||
package me.chanjar.weixin.cp.api; | ||
|
||
import me.chanjar.weixin.common.bean.menu.WxMenu; | ||
import me.chanjar.weixin.common.exception.WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 菜单管理相关接口 | ||
* Created by BinaryWang on 2017/6/24. | ||
* </pre> | ||
* | ||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
*/ | ||
public interface WxCpMenuService { | ||
/** | ||
* <pre> | ||
* 自定义菜单创建接口 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口 | ||
* | ||
* 注意: 这个方法使用WxCpConfigStorage里的agentId | ||
* </pre> | ||
* | ||
* @param menu 菜单对象 | ||
* @see #create(Integer, WxMenu) | ||
*/ | ||
void create(WxMenu menu) throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 自定义菜单创建接口 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单创建接口 | ||
* | ||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 | ||
* </pre> | ||
* | ||
* @param agentId 企业号应用的id | ||
* @param menu 菜单对象 | ||
* @see #create(me.chanjar.weixin.common.bean.menu.WxMenu) | ||
*/ | ||
void create(Integer agentId, WxMenu menu) throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 自定义菜单删除接口 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口 | ||
* | ||
* 注意: 这个方法使用WxCpConfigStorage里的agentId | ||
* </pre> | ||
* | ||
* @see #delete(Integer) | ||
*/ | ||
void delete() throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 自定义菜单删除接口 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单删除接口 | ||
* | ||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 | ||
* </pre> | ||
* | ||
* @param agentId 企业号应用的id | ||
* @see #delete() | ||
*/ | ||
void delete(Integer agentId) throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 自定义菜单查询接口 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口 | ||
* | ||
* 注意: 这个方法使用WxCpConfigStorage里的agentId | ||
* </pre> | ||
* | ||
* @see #get(Integer) | ||
*/ | ||
WxMenu get() throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 自定义菜单查询接口 | ||
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=自定义菜单查询接口 | ||
* | ||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 | ||
* </pre> | ||
* | ||
* @param agentId 企业号应用的id | ||
* @see #get() | ||
*/ | ||
WxMenu get(Integer agentId) throws WxErrorException; | ||
} |
67 changes: 67 additions & 0 deletions
67
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOAuth2Service.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package me.chanjar.weixin.cp.api; | ||
|
||
import me.chanjar.weixin.common.exception.WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* OAuth2相关管理接口 | ||
* Created by BinaryWang on 2017/6/24. | ||
* </pre> | ||
* | ||
* @author <a href="https://github.com/binarywang">Binary Wang</a> | ||
*/ | ||
public interface WxCpOAuth2Service { | ||
/** | ||
* <pre> | ||
* 构造oauth2授权的url连接 | ||
* </pre> | ||
* | ||
* @param state 状态码 | ||
* @return url | ||
*/ | ||
String buildAuthorizationUrl(String state); | ||
|
||
/** | ||
* <pre> | ||
* 构造oauth2授权的url连接 | ||
* 详情请见: http://qydev.weixin.qq.com/wiki/index.php?title=企业获取code | ||
* </pre> | ||
* | ||
* @param redirectUri 跳转链接地址 | ||
* @param state 状态码 | ||
* @return url | ||
*/ | ||
String buildAuthorizationUrl(String redirectUri, String state); | ||
|
||
/** | ||
* <pre> | ||
* 用oauth2获取用户信息 | ||
* http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息 | ||
* 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。 | ||
* | ||
* 注意: 这个方法使用WxCpConfigStorage里的agentId | ||
* </pre> | ||
* | ||
* @param code 微信oauth授权返回的代码 | ||
* @return [userid, deviceid] | ||
* @see #getUserInfo(Integer, String) | ||
*/ | ||
String[] getUserInfo(String code) throws WxErrorException; | ||
|
||
/** | ||
* <pre> | ||
* 用oauth2获取用户信息 | ||
* http://qydev.weixin.qq.com/wiki/index.php?title=根据code获取成员信息 | ||
* 因为企业号oauth2.0必须在应用设置里设置通过ICP备案的可信域名,所以无法测试,因此这个方法很可能是坏的。 | ||
* | ||
* 注意: 这个方法不使用WxCpConfigStorage里的agentId,需要开发人员自己给出 | ||
* </pre> | ||
* | ||
* @param agentId 企业号应用的id | ||
* @param code 微信oauth授权返回的代码 | ||
* @return [userid, deviceid] | ||
* @see #getUserInfo(String) | ||
*/ | ||
String[] getUserInfo(Integer agentId, String code) throws WxErrorException; | ||
|
||
} |
11 changes: 0 additions & 11 deletions
11
weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpOauth2Service.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.