mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-03-10 00:13:40 +08:00
🎨 【小程序】同城配送查询门店余额接口补充了几个遗漏属性,同时优化代码,避免可能出现的NPE问题
This commit is contained in:
@@ -302,7 +302,7 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
if (isApiSignatureRequired(url)) {
|
||||
// 接口需要签名
|
||||
log.debug("已经配置接口需要签名,接口{}将走加密访问路径", url);
|
||||
JsonObject jsonObject = GSON.fromJson(postData, JsonObject.class);
|
||||
JsonObject jsonObject = GSON.fromJson(postData == null ? "{}" : postData, JsonObject.class);
|
||||
return postWithSignature(url, jsonObject);
|
||||
} else {
|
||||
return execute(SimplePostRequestExecutor.create(this), url, postData);
|
||||
@@ -323,12 +323,12 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
|
||||
@Override
|
||||
public String post(String url, ToJson obj) throws WxErrorException {
|
||||
return this.post(url, obj.toJson());
|
||||
return this.post(url, obj == null ? "{}" : obj.toJson());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String post(String url, JsonObject jsonObject) throws WxErrorException {
|
||||
return this.post(url, jsonObject.toString());
|
||||
return this.post(url, jsonObject == null ? "{}" : jsonObject.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -845,7 +845,12 @@ public abstract class BaseWxMaServiceImpl<H, P> implements WxMaService, RequestH
|
||||
new GsonBuilder()
|
||||
.setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES)
|
||||
.create();
|
||||
JsonObject jsonObject = gson.toJsonTree(obj).getAsJsonObject();
|
||||
JsonObject jsonObject;
|
||||
if (obj == null) {
|
||||
jsonObject = gson.fromJson("{}", JsonObject.class);
|
||||
} else {
|
||||
jsonObject = gson.toJsonTree(obj).getAsJsonObject();
|
||||
}
|
||||
return this.postWithSignature(url, jsonObject);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user