Commit 1d2d9100 authored by Quxl's avatar Quxl

x

parent 6adf7707
package com.egolm.pds.config;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
......@@ -77,26 +76,19 @@ public class HttpUtil {
}
}
public static String post(String requestUrl, Map<String, Object> parameters, Map<String, String> headers) {
public static String post(String requestUrl, Map<String, String> headers) {
HttpURLConnection connection = null;
PrintWriter out;
try {
URL getUrl = new URL(requestUrl);
connection = (HttpURLConnection) getUrl.openConnection();
connection.setRequestMethod("POST");
connection.setRequestProperty("Accept-Charset", "utf-8");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Content-Type", "application/json");
if (headers != null) {
for (String key : headers.keySet()) {
connection.setRequestProperty(key, headers.get(key));
}
}
connection.setDoOutput(true);
connection.setDoInput(true);
out = new PrintWriter(connection.getOutputStream());
String queryString = toQueryString(parameters);
out.print(queryString);
out.flush();
connection.connect();
return responseBody(connection);
} catch (Exception e) {
......
......@@ -29,11 +29,9 @@ public class PdsService {
@Transactional
public void savePdsProduct(Object transactionId, Map<String, Object> productMap) {
jdbcTemplate.save("pds_article", productMap);
Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, String> headers = new HashMap<String, String>();
headers.put(authKey, authValue);
parameters.put("transaction_id", transactionId == null ? null : transactionId.toString());
HttpUtil.post(urlUpdate, parameters, headers);
HttpUtil.post(urlUpdate + "/" + transactionId, headers);
}
public JdbcTemplate getJdbcTemplate() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment