From c244f84ba34cb208ad528219bca889b1bc92335f Mon Sep 17 00:00:00 2001 From: tanghc Date: Thu, 6 Jun 2019 18:10:09 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ResultAppender?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java | 4 ++-- .../com/gitee/sop/gatewaycommon/result/ResultAppender.java | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java index 7665577c..ab7394e4 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java @@ -181,7 +181,7 @@ public abstract class BaseExecutorAdapter implements ResultExecutor public String merge(T exchange, JSONObject jsonObjectService) { JSONObject ret = new JSONObject(); String name = "error"; - Map params = this.getApiParam(exchange); + Map params = this.getApiParam(exchange); if (params != null) { Object method = params.get(ParamNames.API_NAME); if (method != null) { @@ -196,7 +196,7 @@ public abstract class BaseExecutorAdapter implements ResultExecutor this.appendReturnSign(apiConfig, params, ret); ResultAppender resultAppender = apiConfig.getResultAppender(); if (resultAppender != null) { - resultAppender.append(ret, params); + resultAppender.append(ret, params, exchange); } return ret.toJSONString(); } diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultAppender.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultAppender.java index 210079de..38954cd5 100644 --- a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultAppender.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultAppender.java @@ -6,13 +6,16 @@ import java.util.Map; /** * 对结果进行追加 + * * @author tanghc */ public interface ResultAppender { /** * 追加最终结果 + * * @param result 最终结果 * @param params 请求参数 + * @param ctx 请求上下文,zuul对应的是RequestContext,Gateway对应的是exchange */ - void append(JSONObject result, Map params); + void append(JSONObject result, Map params, Object ctx); }