开放low-level方法,当本项目跟不上微信api的更新速度的时候,开发人员还可以使用

This commit is contained in:
Daniel Qian 2014-11-01 13:57:02 +08:00
parent 294ad07259
commit d659e5b621
4 changed files with 91 additions and 5 deletions

View File

@ -7,6 +7,7 @@ import java.util.List;
import me.chanjar.weixin.common.bean.WxMenu;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.cp.bean.*;
import me.chanjar.weixin.cp.bean.WxCpDepart;
import me.chanjar.weixin.cp.bean.WxCpUser;
@ -65,8 +66,8 @@ public interface WxCpService {
* 详情请见: http://mp.weixin.qq.com/wiki/index.php?title=上传下载多媒体文件
* </pre>
*
* @param mediaType 媒体类型, 请看{@link WxConsts}
* @param fileType 文件类型请看{@link WxConsts}
* @param mediaType 媒体类型, 请看{@link me.chanjar.weixin.common.api.WxConsts}
* @param fileType 文件类型请看{@link me.chanjar.weixin.common.api.WxConsts}
* @param inputStream 输入流
* @throws WxErrorException
*/
@ -281,6 +282,40 @@ public interface WxCpService {
*/
public void tagRemoveUsers(String tagId, List<String> userIds) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求
* @param url
* @param queryParam
* @return
* @throws WxErrorException
*/
String get(String url, String queryParam) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的POST请求
* @param url
* @param postData
* @return
* @throws WxErrorException
*/
String post(String url, String postData) throws WxErrorException;
/**
* <pre>
* Service没有实现某个API的时候可以用这个
* {@link #get}{@link #post}方法更灵活可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型
* 可以参考{@link me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor}的实现方法
* </pre>
* @param executor
* @param uri
* @param data
* @param <T>
* @param <E>
* @return
* @throws WxErrorException
*/
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException;
/**
* 注入 {@link WxCpConfigStorage} 的实现
*

View File

@ -308,6 +308,14 @@ public class WxCpServiceImpl implements WxCpService {
execute(new SimplePostRequestExecutor(), url, jsonObject.toString());
}
public String get(String url, String queryParam) throws WxErrorException {
return execute(new SimpleGetRequestExecutor(), url, queryParam);
}
public String post(String url, String postData) throws WxErrorException {
return execute(new SimplePostRequestExecutor(), url, postData);
}
/**
* 向微信端发送请求在这里执行的策略是当发生access_token过期时才去刷新然后重新执行请求而不是全局定时请求
*

View File

@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api;
import me.chanjar.weixin.common.bean.WxMenu;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.util.http.RequestExecutor;
import me.chanjar.weixin.mp.bean.*;
import me.chanjar.weixin.mp.bean.result.*;
import me.chanjar.weixin.common.exception.WxErrorException;
@ -318,8 +319,42 @@ public interface WxMpService {
public void templateSend(WxMpTemplateMessage templateMessage) throws WxErrorException;
/**
* 注入 {@link WxMpConfigStorage} 的实现
* @param wxConfigProvider
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的GET请求
* @param url
* @param queryParam
* @return
* @throws WxErrorException
*/
String get(String url, String queryParam) throws WxErrorException;
/**
* 当本Service没有实现某个API的时候可以用这个针对所有微信API中的POST请求
* @param url
* @param postData
* @return
* @throws WxErrorException
*/
String post(String url, String postData) throws WxErrorException;
/**
* <pre>
* Service没有实现某个API的时候可以用这个
* {@link #get}{@link #post}方法更灵活可以自己构造RequestExecutor用来处理不同的参数和不同的返回类型
* 可以参考{@link me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor}的实现方法
* </pre>
* @param executor
* @param uri
* @param data
* @param <T>
* @param <E>
* @return
* @throws WxErrorException
*/
public <T, E> T execute(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException;
/**
* 注入 {@link WxMpConfigStorage} 的实现
* @param wxConfigProvider
*/
public void setWxMpConfigStorage(WxMpConfigStorage wxConfigProvider);
}

View File

@ -279,7 +279,15 @@ public class WxMpServiceImpl implements WxMpService {
execute(new SimplePostRequestExecutor(), url, templateMessage.toJson());
}
/**
public String get(String url, String queryParam) throws WxErrorException {
return execute(new SimpleGetRequestExecutor(), url, queryParam);
}
public String post(String url, String postData) throws WxErrorException {
return execute(new SimplePostRequestExecutor(), url, postData);
}
/**
* 向微信端发送请求在这里执行的策略是当发生access_token过期时才去刷新然后重新执行请求而不是全局定时请求
* @param executor
* @param uri