修复 #80 menuCreate()方法代码的问题,and reformat code

This commit is contained in:
Binary Wang
2016-11-21 11:58:41 +08:00
parent e4d5545f3d
commit 72d6aadd97

View File

@@ -23,7 +23,6 @@ import me.chanjar.weixin.cp.bean.WxCpUser;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
@@ -118,8 +117,6 @@ public class WxCpServiceImpl implements WxCpService {
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);
this.configStorage.updateAccessToken(
accessToken.getAccessToken(), accessToken.getExpiresIn());
} catch (ClientProtocolException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -245,7 +242,7 @@ public class WxCpServiceImpl implements WxCpService {
String url = "https://qyapi.weixin.qq.com/cgi-bin/media/get";
return execute(
new MediaDownloadRequestExecutor(
this.configStorage.getTmpDirFile()),
this.configStorage.getTmpDirFile()),
url, "media_id=" + media_id);
}
@@ -313,8 +310,8 @@ this.configStorage.getTmpDirFile()),
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete";
JsonObject jsonObject = new JsonObject();
JsonArray jsonArray = new JsonArray();
for (int i = 0; i < userids.length; i++) {
jsonArray.add(new JsonPrimitive(userids[i]));
for (String userid : userids) {
jsonArray.add(new JsonPrimitive(userid));
}
jsonObject.add("useridlist", jsonArray);
post(url, jsonObject.toString());
@@ -462,7 +459,7 @@ this.configStorage.getTmpDirFile()),
@Override
public String oauth2buildAuthorizationUrl(String state) {
return this.oauth2buildAuthorizationUrl(
this.configStorage.getOauth2redirectUri(),
this.configStorage.getOauth2redirectUri(),
state
);
}
@@ -544,7 +541,7 @@ this.configStorage.getOauth2redirectUri(),
return executeInternal(executor, uri, data);
} catch (WxErrorException e) {
WxError error = e.getError();
/**
/*
* -1 系统繁忙, 1000ms后重试
*/
if (error.getErrorCode() == -1) {
@@ -566,7 +563,7 @@ this.configStorage.getOauth2redirectUri(),
}
protected synchronized <T, E> T executeInternal(RequestExecutor<T, E> executor, String uri, E data) throws WxErrorException {
if (uri.indexOf("access_token=") != -1) {
if (uri.contains("access_token=")) {
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
}
String accessToken = getAccessToken(false);
@@ -593,8 +590,6 @@ this.configStorage.getOauth2redirectUri(),
throw new WxErrorException(error);
}
return null;
} catch (ClientProtocolException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}