新增调用DS请求相关工具类

20230922-ljl-fixBug
wangchaoxu 1 year ago
parent 582750accf
commit 6b4af840f6

@ -22,13 +22,13 @@ public class DsRequestService implements ExtensionServiceHandler<ItemDTO, Intege
@Override
public BaseResponse<Integer> handle(BaseRequest<ItemDTO> req) {
MultiValueMap params = new LinkedMultiValueMap();
params.add("platform", "ddMicroApp");
Map params = new HashMap();
params.put("platform", "ddMicroApp");
params.add("platformOrderId", "2332");
params.add("shopId", "78327");
params.add("operateInfo", "{\"userId\":\"2332\", \"ip\": \"123.21.123.123\"}");
params.add("platformSkuId", "123232");
params.put("platformOrderId", "2332");
params.put("shopId", "78327");
params.put("operateInfo", "{\"userId\":\"2332\", \"ip\": \"123.21.123.123\"}");
params.put("platformSkuId", "123232");
try {
String res = dsRequestTemplate.execute("/order/cancelPurchaseOrderRelate", params);
log.info(res);

@ -8,6 +8,8 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.StringUtils;
import java.util.Arrays;
@ -61,18 +63,23 @@ public class DsRequestTemplate {
Set<String> keySet = data.keySet();
String[] keyArray = keySet.toArray(new String[0]);
Arrays.sort(keyArray);
MultiValueMap params = new LinkedMultiValueMap();
StringBuilder sb = new StringBuilder();
sb.append(dsToken);
for (int i = 0; i < keyArray.length; i++) {
if (String.valueOf(data.get(keyArray[i])).length() > 0) {
sb.append(keyArray[i]).append(data.get(keyArray[i]));
params.add(keyArray[i], data.get(keyArray[i]));
}
}
sb.append(dsToken);
log.info("sdsdsdsdsdsdsdsdsdsdsdsdsdsdsdsd");
log.info(sb.toString());
String sign = SecureUtil.md5(sb.toString());
headers.set("x-dd-micro-app-sign", sign);
return cloudRequestTemplate.executePost(dsHost + url, body, headers);
return cloudRequestTemplate.executePost(dsHost + url, params, headers);
}
}

Loading…
Cancel
Save