优化ResultAppender

1.x 1.10.0
tanghc 6 years ago
parent 3be7610ae6
commit c244f84ba3
  1. 4
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java
  2. 5
      sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultAppender.java

@ -181,7 +181,7 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
public String merge(T exchange, JSONObject jsonObjectService) { public String merge(T exchange, JSONObject jsonObjectService) {
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
String name = "error"; String name = "error";
Map<String, ?> params = this.getApiParam(exchange); Map<String, Object> params = this.getApiParam(exchange);
if (params != null) { if (params != null) {
Object method = params.get(ParamNames.API_NAME); Object method = params.get(ParamNames.API_NAME);
if (method != null) { if (method != null) {
@ -196,7 +196,7 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R>
this.appendReturnSign(apiConfig, params, ret); this.appendReturnSign(apiConfig, params, ret);
ResultAppender resultAppender = apiConfig.getResultAppender(); ResultAppender resultAppender = apiConfig.getResultAppender();
if (resultAppender != null) { if (resultAppender != null) {
resultAppender.append(ret, params); resultAppender.append(ret, params, exchange);
} }
return ret.toJSONString(); return ret.toJSONString();
} }

@ -6,13 +6,16 @@ import java.util.Map;
/** /**
* 对结果进行追加 * 对结果进行追加
*
* @author tanghc * @author tanghc
*/ */
public interface ResultAppender { public interface ResultAppender {
/** /**
* 追加最终结果 * 追加最终结果
*
* @param result 最终结果 * @param result 最终结果
* @param params 请求参数 * @param params 请求参数
* @param ctx 请求上下文zuul对应的是RequestContextGateway对应的是exchange
*/ */
void append(JSONObject result, Map<String, ?> params); void append(JSONObject result, Map<String, Object> params, Object ctx);
} }

Loading…
Cancel
Save