|
@@ -9,6 +9,7 @@ import org.springframework.http.HttpEntity;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.http.HttpMethod;
|
|
import org.springframework.http.HttpStatus;
|
|
import org.springframework.http.HttpStatus;
|
|
|
|
+import org.springframework.http.MediaType;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.http.ResponseEntity;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
import org.springframework.util.MultiValueMap;
|
|
@@ -42,14 +43,13 @@ public abstract class CloudClientSupport {
|
|
/**
|
|
/**
|
|
* 接口日志
|
|
* 接口日志
|
|
*/
|
|
*/
|
|
- protected static final ExamCloudLog INTERFACE_LOG = ExamCloudLogFactory
|
|
|
|
- .getLog("INTERFACE_LOGGER");
|
|
|
|
|
|
+ protected static final ExamCloudLog INTERFACE_LOG = ExamCloudLogFactory.getLog("INTERFACE_LOGGER");
|
|
|
|
|
|
private RestTemplate restTemplate;
|
|
private RestTemplate restTemplate;
|
|
|
|
|
|
private LogProperties logProperties;
|
|
private LogProperties logProperties;
|
|
|
|
|
|
- private static String[] excludeFields = new String[]{"password", ".*Password"};
|
|
|
|
|
|
+ private static String[] excludeFields = new String[] { "password", ".*Password" };
|
|
|
|
|
|
private LogProperties getLogProperties() {
|
|
private LogProperties getLogProperties() {
|
|
if (null == logProperties) {
|
|
if (null == logProperties) {
|
|
@@ -169,8 +169,8 @@ public abstract class CloudClientSupport {
|
|
httpHeaders.add("App-Id", String.valueOf(AppSelfHolder.get().getAppId()));
|
|
httpHeaders.add("App-Id", String.valueOf(AppSelfHolder.get().getAppId()));
|
|
httpHeaders.add("App-Code", String.valueOf(AppSelfHolder.get().getAppCode()));
|
|
httpHeaders.add("App-Code", String.valueOf(AppSelfHolder.get().getAppCode()));
|
|
|
|
|
|
- String joinStr = StringUtil.join(AppSelfHolder.get().getAppId(),
|
|
|
|
- AppSelfHolder.get().getAppCode(), startTime, AppSelfHolder.get().getSecretKey());
|
|
|
|
|
|
+ String joinStr = StringUtil.join(AppSelfHolder.get().getAppId(), AppSelfHolder.get().getAppCode(), startTime,
|
|
|
|
+ AppSelfHolder.get().getSecretKey());
|
|
byte[] bytes = SHA256.encode(joinStr);
|
|
byte[] bytes = SHA256.encode(joinStr);
|
|
String accessToken = ByteUtil.toHexAscii(bytes);
|
|
String accessToken = ByteUtil.toHexAscii(bytes);
|
|
httpHeaders.add("Access-Token", accessToken);
|
|
httpHeaders.add("Access-Token", accessToken);
|
|
@@ -193,8 +193,7 @@ public abstract class CloudClientSupport {
|
|
|
|
|
|
T respBody = null;
|
|
T respBody = null;
|
|
try {
|
|
try {
|
|
- ResponseEntity<String> respEntity = getRestTemplate().exchange(url, method,
|
|
|
|
- requestEntity, String.class);
|
|
|
|
|
|
+ ResponseEntity<String> respEntity = getRestTemplate().exchange(url, method, requestEntity, String.class);
|
|
respBody = getRespBody(respEntity, responseType);
|
|
respBody = getRespBody(respEntity, responseType);
|
|
|
|
|
|
if (INTERFACE_LOG.isDebugEnabled() && getLogProperties().isNormalResponseLogEnable()) {
|
|
if (INTERFACE_LOG.isDebugEnabled() && getLogProperties().isNormalResponseLogEnable()) {
|
|
@@ -232,8 +231,7 @@ public abstract class CloudClientSupport {
|
|
* @param responseType
|
|
* @param responseType
|
|
* @return
|
|
* @return
|
|
*/
|
|
*/
|
|
- protected <T> T post(String appName, String requestMapping, BaseRequest body,
|
|
|
|
- Class<T> responseType) {
|
|
|
|
|
|
+ protected <T> T post(String appName, String requestMapping, BaseRequest body, Class<T> responseType) {
|
|
String url = buildUrl(appName, requestMapping);
|
|
String url = buildUrl(appName, requestMapping);
|
|
return exchange(url, HttpMethod.POST, body, responseType);
|
|
return exchange(url, HttpMethod.POST, body, responseType);
|
|
}
|
|
}
|
|
@@ -270,12 +268,13 @@ public abstract class CloudClientSupport {
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
- public <T> T postForm(String appName, String requestMapping, FormRequest req,
|
|
|
|
- Class<T> responseType) {
|
|
|
|
|
|
+ public <T> T postForm(String appName, String requestMapping, FormRequest req, Class<T> responseType) {
|
|
String url = buildUrl(appName, requestMapping);
|
|
String url = buildUrl(appName, requestMapping);
|
|
|
|
|
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
MultiValueMap<String, Object> params = new LinkedMultiValueMap<>();
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
HttpHeaders httpHeaders = new HttpHeaders();
|
|
|
|
+ MediaType type = MediaType.parseMediaType("multipart/form-data");
|
|
|
|
+ httpHeaders.setContentType(type);
|
|
|
|
|
|
List<FormFilePart> formFilePartList = req.getFormFilePartList();
|
|
List<FormFilePart> formFilePartList = req.getFormFilePartList();
|
|
for (FormFilePart part : formFilePartList) {
|
|
for (FormFilePart part : formFilePartList) {
|