|
@@ -8,6 +8,8 @@ import com.hrsk.cloud.eg.domain.api.ValueObject;
|
|
import com.hrsk.cloud.eg.domain.common.utils.GsonUtils;
|
|
import com.hrsk.cloud.eg.domain.common.utils.GsonUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* @author: bianlanzhou
|
|
* @author: bianlanzhou
|
|
* @create: 2024-08-01 15:38
|
|
* @create: 2024-08-01 15:38
|
|
@@ -31,7 +33,7 @@ public class ApiJsonResultResolver implements ApiResultResolver {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public Object resolve(String jsonTemplate, ApiResult context) {
|
|
|
|
|
|
+ public Object resolve(String jsonTemplate, Map<String,Object> context) {
|
|
JsonElement jsonElement = GsonUtils.fromJson(jsonTemplate, JsonElement.class);
|
|
JsonElement jsonElement = GsonUtils.fromJson(jsonTemplate, JsonElement.class);
|
|
traverseJson(jsonElement,jsonElement,null,context,0);
|
|
traverseJson(jsonElement,jsonElement,null,context,0);
|
|
return jsonElement.toString();
|
|
return jsonElement.toString();
|
|
@@ -42,7 +44,7 @@ public class ApiJsonResultResolver implements ApiResultResolver {
|
|
* @param context 上下文
|
|
* @param context 上下文
|
|
* @param deep 深度
|
|
* @param deep 深度
|
|
*/
|
|
*/
|
|
- public void traverseJson(JsonElement jsonElement, JsonElement currentElement,String currentKey,ApiResult context,Integer deep) {
|
|
|
|
|
|
+ public void traverseJson(JsonElement jsonElement, JsonElement currentElement,String currentKey,Map<String,Object> context,Integer deep) {
|
|
deep++;
|
|
deep++;
|
|
if(deep >= MAX_DEEP){
|
|
if(deep >= MAX_DEEP){
|
|
throw new BizException(String.format("请求payload的json配置深度达到允许的最大深度[%s]!",MAX_DEEP));
|
|
throw new BizException(String.format("请求payload的json配置深度达到允许的最大深度[%s]!",MAX_DEEP));
|
|
@@ -110,7 +112,7 @@ public class ApiJsonResultResolver implements ApiResultResolver {
|
|
* 将spel表达式转换成真实值
|
|
* 将spel表达式转换成真实值
|
|
* @param jsonElement json元素
|
|
* @param jsonElement json元素
|
|
*/
|
|
*/
|
|
- private JsonPrimitive parseSpelConfigToRealValue(JsonElement jsonElement, ApiResult context){
|
|
|
|
|
|
+ private JsonPrimitive parseSpelConfigToRealValue(JsonElement jsonElement, Map<String,Object> context){
|
|
String value = jsonElement.getAsString();
|
|
String value = jsonElement.getAsString();
|
|
value = StringUtils.replace(value,CONFIG_PREFIX_SIGN,"{",3);
|
|
value = StringUtils.replace(value,CONFIG_PREFIX_SIGN,"{",3);
|
|
ValueObject valueObject = new Gson().fromJson(value,ValueObject.class);
|
|
ValueObject valueObject = new Gson().fromJson(value,ValueObject.class);
|