mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-15 02:35:08 +08:00
fix some code
This commit is contained in:
@@ -8,20 +8,15 @@ public interface RequestHttp<H, P> {
|
|||||||
/**
|
/**
|
||||||
* 返回httpClient
|
* 返回httpClient
|
||||||
*
|
*
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
H getRequestHttpClient();
|
H getRequestHttpClient();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回httpProxy
|
* 返回httpProxy
|
||||||
*
|
*
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
P getRequestHttpProxy();
|
P getRequestHttpProxy();
|
||||||
|
|
||||||
/**
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
HttpType getRequestType();
|
HttpType getRequestType();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -12,11 +12,10 @@ import me.chanjar.weixin.common.util.http.okhttp.OkHttpSimpleGetRequestExecutor;
|
|||||||
public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor<String, String> {
|
public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor<String, String> {
|
||||||
protected RequestHttp<H, P> requestHttp;
|
protected RequestHttp<H, P> requestHttp;
|
||||||
|
|
||||||
public SimpleGetRequestExecutor(RequestHttp requestHttp) {
|
public SimpleGetRequestExecutor(RequestHttp<H, P> requestHttp) {
|
||||||
this.requestHttp = requestHttp;
|
this.requestHttp = requestHttp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static RequestExecutor<String, String> create(RequestHttp requestHttp) {
|
public static RequestExecutor<String, String> create(RequestHttp requestHttp) {
|
||||||
switch (requestHttp.getRequestType()) {
|
switch (requestHttp.getRequestType()) {
|
||||||
case APACHE_HTTP:
|
case APACHE_HTTP:
|
||||||
@@ -26,7 +25,7 @@ public abstract class SimpleGetRequestExecutor<H, P> implements RequestExecutor<
|
|||||||
case OK_HTTP:
|
case OK_HTTP:
|
||||||
return new OkHttpSimpleGetRequestExecutor(requestHttp);
|
return new OkHttpSimpleGetRequestExecutor(requestHttp);
|
||||||
default:
|
default:
|
||||||
return null;
|
throw new IllegalArgumentException("非法请求参数");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -210,8 +210,7 @@ public abstract class AbstractWxMpServiceImpl<H, P> implements WxMpService, Requ
|
|||||||
String url = String.format(WxMpService.OAUTH2_VALIDATE_TOKEN_URL, oAuth2AccessToken.getAccessToken(), oAuth2AccessToken.getOpenId());
|
String url = String.format(WxMpService.OAUTH2_VALIDATE_TOKEN_URL, oAuth2AccessToken.getAccessToken(), oAuth2AccessToken.getOpenId());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
RequestExecutor<String, String> executor = SimpleGetRequestExecutor.create(this);
|
SimpleGetRequestExecutor.create(this).execute(url, null);
|
||||||
executor.execute(url, null);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
|
Reference in New Issue
Block a user