From e4c1863a66537ef8909bb3d9d74d9bc70268c80f Mon Sep 17 00:00:00 2001 From: xingzi <1771761586@qq.com> Date: Sun, 30 May 2021 18:00:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9-=E5=BD=93=E6=97=A0=E5=AD=97?= =?UTF-8?q?=E5=85=B8=E6=97=B6=E4=B8=8D=E6=8E=A8=E9=80=81=E5=AD=97=E5=85=B8?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/power/doc/builder/TornaBuilder.java | 13 +++++++++---- .../com/power/doc/builder/rpc/RpcTornaBuilder.java | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/power/doc/builder/TornaBuilder.java b/src/main/java/com/power/doc/builder/TornaBuilder.java index 463ba163..5d4906b0 100644 --- a/src/main/java/com/power/doc/builder/TornaBuilder.java +++ b/src/main/java/com/power/doc/builder/TornaBuilder.java @@ -23,6 +23,7 @@ package com.power.doc.builder; import com.google.gson.Gson; +import com.power.common.util.CollectionUtil; import com.power.common.util.OkHttp3Util; import com.power.common.util.StringUtil; import com.power.doc.constants.TornaConstants; @@ -108,14 +109,18 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig, JavaPro //推送字典信息 Map dicMap = new HashMap<>(2); List docDicts = TornaUtil.buildTornaDic(DocUtil.buildDictionary(apiConfig, builder)); - dicMap.put("enums", docDicts); - Map dicRequestJson = TornaConstants.buildParams(ENUM_PUSH, new Gson().toJson(dicMap), apiConfig); + if(CollectionUtil.isNotEmpty(docDicts)) { + dicMap.put("enums", docDicts); + Map dicRequestJson = TornaConstants.buildParams(ENUM_PUSH, new Gson().toJson(dicMap), apiConfig); + String dicResponseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(dicRequestJson)); + TornaUtil.printDebugInfo(apiConfig, dicResponseMsg, dicRequestJson, ENUM_PUSH); + } //获取返回结果 String responseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(requestJson)); - String dicResponseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(dicRequestJson)); + //开启调试时打印请求信息 TornaUtil.printDebugInfo(apiConfig, responseMsg, requestJson, PUSH); - TornaUtil.printDebugInfo(apiConfig, dicResponseMsg, dicRequestJson, ENUM_PUSH); + } } diff --git a/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java b/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java index b9a2f767..6bf0b045 100644 --- a/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java +++ b/src/main/java/com/power/doc/builder/rpc/RpcTornaBuilder.java @@ -23,6 +23,7 @@ package com.power.doc.builder.rpc; import com.google.gson.Gson; +import com.power.common.util.CollectionUtil; import com.power.common.util.OkHttp3Util; import com.power.common.util.StringUtil; import com.power.doc.builder.ProjectDocConfigBuilder; @@ -111,13 +112,17 @@ public static void buildTorna(List apiDocs, ApiConfig apiConfig,JavaP //推送字典信息 Map dicMap = new HashMap<>(2); List docDicts =TornaUtil.buildTornaDic(DocUtil.buildDictionary(apiConfig,builder)); - dicMap.put("enums",docDicts); + + if(CollectionUtil.isNotEmpty(docDicts)) { + dicMap.put("enums", docDicts); + Map dicRequestJson = TornaConstants.buildParams(ENUM_PUSH, new Gson().toJson(dicMap), apiConfig); + String dicResponseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(dicRequestJson)); + TornaUtil.printDebugInfo(apiConfig, dicResponseMsg, dicRequestJson, ENUM_PUSH); + } Map dicRequestJson = TornaConstants.buildParams(ENUM_PUSH, new Gson().toJson(dicMap), apiConfig); //获取返回结果 String responseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(requestJson)); - String dicResponseMsg = OkHttp3Util.syncPostJson(apiConfig.getOpenUrl(), new Gson().toJson(dicRequestJson)); //开启调试时打印请求信息 TornaUtil.printDebugInfo(apiConfig, responseMsg, requestJson,PUSH); - TornaUtil.printDebugInfo(apiConfig, dicResponseMsg, dicRequestJson,ENUM_PUSH); } }