|
|
@ -120,25 +120,19 @@ 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"; |
|
|
|
String sign = ""; |
|
|
|
|
|
|
|
Map<String, ?> params = this.getApiParam(exchange); |
|
|
|
Map<String, ?> 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) { |
|
|
|
name = String.valueOf(method); |
|
|
|
name = String.valueOf(method); |
|
|
|
} |
|
|
|
} |
|
|
|
Object clientSign = params.get(ParamNames.SIGN_NAME); |
|
|
|
|
|
|
|
if (clientSign != null) { |
|
|
|
|
|
|
|
sign = String.valueOf(clientSign); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
ApiConfig apiConfig = ApiConfig.getInstance(); |
|
|
|
ApiConfig apiConfig = ApiConfig.getInstance(); |
|
|
|
// 点换成下划线
|
|
|
|
// 点换成下划线
|
|
|
|
DataNameBuilder dataNameBuilder = apiConfig.getDataNameBuilder(); |
|
|
|
DataNameBuilder dataNameBuilder = apiConfig.getDataNameBuilder(); |
|
|
|
String method = dataNameBuilder.build(name); |
|
|
|
String method = dataNameBuilder.build(name); |
|
|
|
ret.put(method, jsonObjectService); |
|
|
|
ret.put(method, jsonObjectService); |
|
|
|
// 先隐藏返回签名字段
|
|
|
|
this.appendReturnSign(apiConfig, params, ret); |
|
|
|
ret.put(ParamNames.SIGN_NAME, sign); |
|
|
|
|
|
|
|
ResultAppender resultAppender = apiConfig.getResultAppender(); |
|
|
|
ResultAppender resultAppender = apiConfig.getResultAppender(); |
|
|
|
if (resultAppender != null) { |
|
|
|
if (resultAppender != null) { |
|
|
|
resultAppender.append(ret, params); |
|
|
|
resultAppender.append(ret, params); |
|
|
@ -146,4 +140,22 @@ public abstract class BaseExecutorAdapter<T, R> implements ResultExecutor<T, R> |
|
|
|
return ret.toJSONString(); |
|
|
|
return ret.toJSONString(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected void appendReturnSign(ApiConfig apiConfig, Map<String, ?> params, JSONObject ret) { |
|
|
|
|
|
|
|
if (apiConfig.isShowReturnSign() && params != null) { |
|
|
|
|
|
|
|
Object appKey = params.get(ParamNames.APP_KEY_NAME); |
|
|
|
|
|
|
|
String sign = this.createReturnSign(String.valueOf(appKey)); |
|
|
|
|
|
|
|
ret.put(ParamNames.SIGN_NAME, sign); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 这里需要使用平台的私钥生成一个sign,需要配置两套公私钥。目前暂未实现 |
|
|
|
|
|
|
|
* @param appKey |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
protected String createReturnSign(String appKey) { |
|
|
|
|
|
|
|
// TODO: 返回sign
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|