处理post的json请求主体丢失问题

This commit is contained in:
wanggeng 2021-09-30 11:55:08 +08:00
parent 4342b6ab30
commit e8bdc1ace5
4 changed files with 20 additions and 2 deletions

View File

@ -18,6 +18,7 @@ import org.springframework.context.annotation.Configuration;
public class MiniappProperties { public class MiniappProperties {
private Boolean active; private Boolean active;
private String apiUrl;
private String authorizeUrl; private String authorizeUrl;
private String grantType; private String grantType;
private String appKey; private String appKey;
@ -31,6 +32,14 @@ public class MiniappProperties {
this.active = active; this.active = active;
} }
public String getApiUrl() {
return apiUrl == null ? "" : apiUrl.trim();
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public String getAuthorizeUrl() { public String getAuthorizeUrl() {
return authorizeUrl == null ? "" : authorizeUrl; return authorizeUrl == null ? "" : authorizeUrl;
} }

View File

@ -19,6 +19,7 @@ public class OfficialAccountProperties {
private Boolean apiCrossOrigin; private Boolean apiCrossOrigin;
private Boolean activate; private Boolean activate;
private String apiUrl;
private OfficialAccountAuthorizeProperties authorize; private OfficialAccountAuthorizeProperties authorize;
private String accessTokenUrl; private String accessTokenUrl;
private String appId; private String appId;
@ -42,6 +43,14 @@ public class OfficialAccountProperties {
this.activate = activate; this.activate = activate;
} }
public String getApiUrl() {
return apiUrl == null ? "" : apiUrl.trim();
}
public void setApiUrl(String apiUrl) {
this.apiUrl = apiUrl;
}
public OfficialAccountAuthorizeProperties getAuthorize() { public OfficialAccountAuthorizeProperties getAuthorize() {
return authorize; return authorize;
} }

View File

@ -81,7 +81,7 @@ public class RestRemoteHandler implements InvocationHandler {
RemotePostMethod postMethod = method.getAnnotation(RemotePostMethod.class); RemotePostMethod postMethod = method.getAnnotation(RemotePostMethod.class);
uri = postMethod.value(); uri = postMethod.value();
formVariableParams = getFormVariableParams(method.getParameters(), args); formVariableParams = getFormVariableParams(method.getParameters(), args);
if (formVariableParams == null) { if (formVariableParams.isEmpty()) {
requestBody = getRequestBody(method.getParameters(), args); requestBody = getRequestBody(method.getParameters(), args);
} }
} else if (method.isAnnotationPresent(RemotePutMethod.class)) { } else if (method.isAnnotationPresent(RemotePutMethod.class)) {

View File

@ -49,7 +49,7 @@ public class RestRemoteRequest {
result = delete(remoteUri, headers); result = delete(remoteUri, headers);
} else if (RequestMethod.POST.equals(requestMethod)) { } else if (RequestMethod.POST.equals(requestMethod)) {
// form表单优先 // form表单优先
if (formVariableParams != null) { if (!formVariableParams.isEmpty()) {
result = post(remoteUri, headers, formVariableParams); result = post(remoteUri, headers, formVariableParams);
} else { } else {
result = post(remoteUri, headers, jsonBody); result = post(remoteUri, headers, jsonBody);