Commit 1d2d9100 authored by Quxl's avatar Quxl

x

parent 6adf7707
package com.egolm.pds.config; package com.egolm.pds.config;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.URL; import java.net.URL;
...@@ -77,26 +76,19 @@ public class HttpUtil { ...@@ -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; HttpURLConnection connection = null;
PrintWriter out;
try { try {
URL getUrl = new URL(requestUrl); URL getUrl = new URL(requestUrl);
connection = (HttpURLConnection) getUrl.openConnection(); connection = (HttpURLConnection) getUrl.openConnection();
connection.setRequestMethod("POST"); connection.setRequestMethod("POST");
connection.setRequestProperty("Accept-Charset", "utf-8"); connection.setRequestProperty("Accept-Charset", "utf-8");
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded"); connection.setRequestProperty("Content-Type", "application/json");
if (headers != null) { if (headers != null) {
for (String key : headers.keySet()) { for (String key : headers.keySet()) {
connection.setRequestProperty(key, headers.get(key)); 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(); connection.connect();
return responseBody(connection); return responseBody(connection);
} catch (Exception e) { } catch (Exception e) {
......
...@@ -29,11 +29,9 @@ public class PdsService { ...@@ -29,11 +29,9 @@ public class PdsService {
@Transactional @Transactional
public void savePdsProduct(Object transactionId, Map<String, Object> productMap) { public void savePdsProduct(Object transactionId, Map<String, Object> productMap) {
jdbcTemplate.save("pds_article", productMap); jdbcTemplate.save("pds_article", productMap);
Map<String, Object> parameters = new HashMap<String, Object>();
Map<String, String> headers = new HashMap<String, String>(); Map<String, String> headers = new HashMap<String, String>();
headers.put(authKey, authValue); headers.put(authKey, authValue);
parameters.put("transaction_id", transactionId == null ? null : transactionId.toString()); HttpUtil.post(urlUpdate + "/" + transactionId, headers);
HttpUtil.post(urlUpdate, parameters, headers);
} }
public JdbcTemplate getJdbcTemplate() { 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