修复 #80 menuCreate()方法代码的问题,and reformat code
This commit is contained in:
@@ -23,7 +23,6 @@ import me.chanjar.weixin.cp.bean.WxCpUser;
|
|||||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.http.HttpHost;
|
import org.apache.http.HttpHost;
|
||||||
import org.apache.http.client.ClientProtocolException;
|
|
||||||
import org.apache.http.client.config.RequestConfig;
|
import org.apache.http.client.config.RequestConfig;
|
||||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||||
import org.apache.http.client.methods.HttpGet;
|
import org.apache.http.client.methods.HttpGet;
|
||||||
@@ -118,8 +117,6 @@ public class WxCpServiceImpl implements WxCpService {
|
|||||||
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);
|
WxAccessToken accessToken = WxAccessToken.fromJson(resultContent);
|
||||||
this.configStorage.updateAccessToken(
|
this.configStorage.updateAccessToken(
|
||||||
accessToken.getAccessToken(), accessToken.getExpiresIn());
|
accessToken.getAccessToken(), accessToken.getExpiresIn());
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
@@ -313,8 +310,8 @@ this.configStorage.getTmpDirFile()),
|
|||||||
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete";
|
String url = "https://qyapi.weixin.qq.com/cgi-bin/user/batchdelete";
|
||||||
JsonObject jsonObject = new JsonObject();
|
JsonObject jsonObject = new JsonObject();
|
||||||
JsonArray jsonArray = new JsonArray();
|
JsonArray jsonArray = new JsonArray();
|
||||||
for (int i = 0; i < userids.length; i++) {
|
for (String userid : userids) {
|
||||||
jsonArray.add(new JsonPrimitive(userids[i]));
|
jsonArray.add(new JsonPrimitive(userid));
|
||||||
}
|
}
|
||||||
jsonObject.add("useridlist", jsonArray);
|
jsonObject.add("useridlist", jsonArray);
|
||||||
post(url, jsonObject.toString());
|
post(url, jsonObject.toString());
|
||||||
@@ -544,7 +541,7 @@ this.configStorage.getOauth2redirectUri(),
|
|||||||
return executeInternal(executor, uri, data);
|
return executeInternal(executor, uri, data);
|
||||||
} catch (WxErrorException e) {
|
} catch (WxErrorException e) {
|
||||||
WxError error = e.getError();
|
WxError error = e.getError();
|
||||||
/**
|
/*
|
||||||
* -1 系统繁忙, 1000ms后重试
|
* -1 系统繁忙, 1000ms后重试
|
||||||
*/
|
*/
|
||||||
if (error.getErrorCode() == -1) {
|
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 {
|
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);
|
throw new IllegalArgumentException("uri参数中不允许有access_token: " + uri);
|
||||||
}
|
}
|
||||||
String accessToken = getAccessToken(false);
|
String accessToken = getAccessToken(false);
|
||||||
@@ -593,8 +590,6 @@ this.configStorage.getOauth2redirectUri(),
|
|||||||
throw new WxErrorException(error);
|
throw new WxErrorException(error);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
} catch (ClientProtocolException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user