fix(系统设置): 全局前后置脚本变更历史冗余字符去除

--bug=1010776 --user=周骏弘 【环境管理】-前后置脚本变更记录-脚本变更记录格式显示错误 https://www.tapd.cn/55049933/s/1113438
This commit is contained in:
junhong 2022-03-04 00:40:04 +08:00 committed by 刘瑞斌
parent a05dff6b85
commit e439c0b241
1 changed files with 14 additions and 8 deletions

View File

@ -58,26 +58,26 @@ public class ApiTestEnvironmentDiffUtil {
// 对比全局前置脚本(单个请求)
if (!StringUtils.equals(bloBsNew.getString("preProcessor"), bloBsOld.getString("preProcessor"))) {
diffMap.put("preProcessorRaw1", bloBsNew.getString("preProcessor"));
diffMap.put("preProcessorRaw2", bloBsOld.getString("preProcessor"));
diffMap.put("preProcessorRaw1", formatting(bloBsNew.getString("preProcessor")));
diffMap.put("preProcessorRaw2", formatting(bloBsOld.getString("preProcessor")));
}
// 对比全局前置脚本(所有请求)
if (!StringUtils.equals(bloBsNew.getString("preStepProcessor"), bloBsOld.getString("preStepProcessor"))) {
diffMap.put("preStepProcessorRaw1", bloBsNew.getString("preStepProcessor"));
diffMap.put("preStepProcessorRaw2", bloBsOld.getString("preStepProcessor"));
diffMap.put("preStepProcessorRaw1", formatting(bloBsNew.getString("preStepProcessor")));
diffMap.put("preStepProcessorRaw2", formatting(bloBsOld.getString("preStepProcessor")));
}
// 对比全局后置脚本(单个请求)
if (!StringUtils.equals(bloBsNew.getString("postProcessor"), bloBsOld.getString("postProcessor"))) {
diffMap.put("postProcessorRaw1", bloBsNew.getString("postProcessor"));
diffMap.put("postProcessorRaw2", bloBsOld.getString("postProcessor"));
diffMap.put("postProcessorRaw1", formatting(bloBsNew.getString("postProcessor")));
diffMap.put("postProcessorRaw2", formatting(bloBsOld.getString("postProcessor")));
}
// 对比全局后置脚本(所有请求)
if (!StringUtils.equals(bloBsNew.getString("postStepProcessor"), bloBsOld.getString("postStepProcessor"))) {
diffMap.put("postStepProcessorRaw1", bloBsNew.getString("postStepProcessor"));
diffMap.put("postStepProcessorRaw2", bloBsOld.getString("postStepProcessor"));
diffMap.put("postStepProcessorRaw1", formatting(bloBsNew.getString("postStepProcessor")));
diffMap.put("postStepProcessorRaw2", formatting(bloBsOld.getString("postStepProcessor")));
}
if (diffMap.size() > 1) {
@ -88,4 +88,10 @@ public class ApiTestEnvironmentDiffUtil {
}
return null;
}
public static String formatting(String target) {
JSONObject result = JSONObject.parseObject(target);
result.remove("$type");
return result.toJSONString();
}
}