From 96987cec3b5ece0672df2f2f7caca8d6d590ba82 Mon Sep 17 00:00:00 2001 From: duhui Date: Thu, 14 Jul 2022 14:55:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=96=AF=E4=BD=93ios=E6=94=AF=E4=BB=98?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OhayooGetExternalController.java | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/jmfy/controller/OhayooGetExternalController.java b/src/main/java/com/jmfy/controller/OhayooGetExternalController.java index 2fcfdee..3860132 100644 --- a/src/main/java/com/jmfy/controller/OhayooGetExternalController.java +++ b/src/main/java/com/jmfy/controller/OhayooGetExternalController.java @@ -1,5 +1,6 @@ package com.jmfy.controller; +import com.alibaba.fastjson.JSONObject; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.jmfy.paramBean.PaySdkEnum; @@ -8,12 +9,14 @@ import com.jmfy.util.MD5Util; import net.sf.json.JSON; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import java.io.InputStreamReader; import java.security.KeyFactory; import java.security.Signature; import java.security.interfaces.RSAPublicKey; @@ -27,11 +30,18 @@ import java.util.*; public class OhayooGetExternalController { private static final Logger LOGGER = LoggerFactory.getLogger(OhayooGetExternalController.class); - @RequestMapping(value = "/ohayooGetExternal", method = {RequestMethod.POST, RequestMethod.GET}) + @PostMapping(value = "/ohayooGetExternal") public String ohayooGetExternal(HttpServletRequest request) throws Exception { - HashMap parameterMap = JsonUtil.getInstence().getParameterMap2(request); - - TreeMap map = new TreeMap<>(parameterMap); + Gson gson = new Gson(); + TreeMap map = new TreeMap<>(); + InputStreamReader insr = new InputStreamReader(request.getInputStream(),"utf-8"); + String result = ""; + int respInt = insr.read(); + while(respInt != -1) { + result += (char) respInt; + respInt = insr.read(); + } + map = gson.fromJson(result, map.getClass()); LOGGER.info("ohayoo获取前端参数:{}",map); if (map == null || map.isEmpty()) { return null; @@ -46,7 +56,7 @@ public class OhayooGetExternalController { String sign = MD5Util.encrypByMd5(payKey + externalOrder + payKey); map.put("sign",sign); - Gson gson = new Gson(); + LOGGER.info("ohayoo返回前端参数:{}",gson.toJson(map)); return gson.toJson(map);