fix(接口定义): 修复接口定义新值和旧值显示一样的缺陷
--bug=1018995 --user=王孝刚 【接口用例】接口定义变更历史,新值和旧值显示的一样了 https://www.tapd.cn/55049933/s/1283803
This commit is contained in:
parent
81c9b5ad73
commit
ea9eb7b43b
|
@ -132,7 +132,7 @@ public class ApiTestDefinitionDiffUtilImpl implements ApiDefinitionDiffUtil {
|
|||
String headerOld = StringUtils.join(StringUtils.join(JSON_START, JSON.toJSONString(httpOld.getHeaders())), JSON_END);
|
||||
if (!StringUtils.equals(headerNew, headerOld)) {
|
||||
String patch = jsonDiff.diff(headerOld, headerNew);
|
||||
String diffPatch = jsonDiff.apply(headerNew, patch);
|
||||
String diffPatch = jsonDiff.apply(headerOld, patch);
|
||||
if (StringUtils.isNotEmpty(diffPatch)) {
|
||||
diffMap.put("header", diffPatch);
|
||||
}
|
||||
|
@ -146,7 +146,7 @@ public class ApiTestDefinitionDiffUtilImpl implements ApiDefinitionDiffUtil {
|
|||
String queryOld = StringUtils.join(StringUtils.join(JSON_START, JSON.toJSONString(httpOld.getArguments())), JSON_END);
|
||||
if (!StringUtils.equals(queryNew, queryOld)) {
|
||||
String patch = jsonDiff.diff(queryOld, queryNew);
|
||||
String diff = jsonDiff.apply(queryNew, patch);
|
||||
String diff = jsonDiff.apply(queryOld, patch);
|
||||
if (StringUtils.isNotEmpty(diff)) {
|
||||
diffMap.put(QUERY, diff);
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class ApiTestDefinitionDiffUtilImpl implements ApiDefinitionDiffUtil {
|
|||
String restOld = StringUtils.join(StringUtils.join(JSON_START, JSON.toJSONString(httpOld.getRest())), JSON_END);
|
||||
if (!StringUtils.equals(restNew, restOld)) {
|
||||
String patch = jsonDiff.diff(restOld, restNew);
|
||||
String diff = jsonDiff.apply(restNew, patch);
|
||||
String diff = jsonDiff.apply(restOld, patch);
|
||||
if (StringUtils.isNotEmpty(diff)) {
|
||||
diffMap.put("rest", diff);
|
||||
}
|
||||
|
|
|
@ -8,14 +8,18 @@
|
|||
</el-col>
|
||||
<span style="margin-left: 10px" v-else/>
|
||||
<el-col class="item">
|
||||
<input class="el-input el-input__inner" v-if="!suggestions" :disabled="isReadOnly" v-model="item.name" size="small" maxlength="200" show-word-limit :style="item.style"/>
|
||||
<el-autocomplete :disabled="isReadOnly" :maxlength="400" v-if="suggestions" v-model="item.name" size="small" show-word-limit :style="item.style"/>
|
||||
<input class="el-input el-input__inner" v-if="!suggestions" :disabled="isReadOnly" v-model="item.name"
|
||||
size="small" maxlength="200" show-word-limit :style="item.style"/>
|
||||
<el-autocomplete :disabled="isReadOnly" :maxlength="400" v-if="suggestions" v-model="item.name" size="small"
|
||||
show-word-limit :style="item.style"/>
|
||||
</el-col>
|
||||
<el-col v-if="showRequired">
|
||||
<input class="el-input el-input__inner" :disabled="isReadOnly" v-model="item.required" size="small" :style="item.style"/>
|
||||
<input class="el-input el-input__inner" :disabled="isReadOnly" v-model="item.required" size="small"
|
||||
:style="item.style"/>
|
||||
</el-col>
|
||||
<el-col class="item">
|
||||
<input class="el-input el-input__inner" :disabled="isReadOnly" v-model="item.value" size="small" show-word-limit :style="item.style"/>
|
||||
<input class="el-input el-input__inner" :disabled="isReadOnly" v-model="item.value" size="small"
|
||||
show-word-limit :style="item.style"/>
|
||||
</el-col>
|
||||
<el-col class="item" v-if="showDesc">
|
||||
<input class="el-input el-input__inner" v-model="item.description" size="small" maxlength="200"
|
||||
|
@ -131,11 +135,11 @@ export default {
|
|||
newObj[key] = value;
|
||||
}
|
||||
});
|
||||
item.style = background_old;
|
||||
item.style = background_new;
|
||||
this.data.push(item);
|
||||
newObj["box"] = true;
|
||||
newObj["style"] = background_new;
|
||||
newObj["required"] = newObj.required ? this.$t('commons.selector.required') : this.$t('commons.selector.not_required');
|
||||
item["box"] = true;
|
||||
newObj["style"] = background_old;
|
||||
newObj["required"] = newObj.required === this.$t('commons.selector.required') ? this.$t('commons.selector.required') : this.$t('commons.selector.not_required');
|
||||
this.data.push(newObj);
|
||||
} else {
|
||||
this.data.push(item);
|
||||
|
|
|
@ -152,7 +152,7 @@ public class JsonDiff {
|
|||
}
|
||||
Entry<String, JzonElement> childentry = ((JzonObject) partial).entrySet().iterator().next();
|
||||
String childKey = childentry.getKey();
|
||||
Instruction instruction = create(childKey);
|
||||
Instruction instruction = create(childKey, i);
|
||||
boolean newAppliance = false;
|
||||
if (instruction.isIndexed() && !applyTo.isJsonArray()) {
|
||||
applyTo = factory.createJsonArray();
|
||||
|
@ -172,7 +172,7 @@ public class JsonDiff {
|
|||
applyPartial(applyTo, instruction, childentry.getValue());
|
||||
}
|
||||
} else {
|
||||
Instruction instruction = create(key);
|
||||
Instruction instruction = create(key, 0);
|
||||
if (instruction.oper == Oper.INSERT || instruction.oper == Oper.DELETE) {
|
||||
applyPartial(origEl, instruction, value);
|
||||
} else if (instruction.isIndexed()) {
|
||||
|
@ -307,7 +307,7 @@ public class JsonDiff {
|
|||
object.add(DIFF_ADD + "name", new JacksonJsonObject(null));
|
||||
}
|
||||
if (instruction.index > 0 && ((JzonArray) applyTo).size() == instruction.index) {
|
||||
((JzonArray) applyTo).set(instruction.index - 1, object);
|
||||
((JzonArray) applyTo).set(instruction.index, object);
|
||||
} else {
|
||||
((JzonArray) applyTo).set(instruction.index, object);
|
||||
}
|
||||
|
@ -335,11 +335,12 @@ public class JsonDiff {
|
|||
}
|
||||
}
|
||||
|
||||
Instruction create(String childKey) {
|
||||
Instruction create(String childKey, int i) {
|
||||
Instruction instruction = new Instruction();
|
||||
if (childKey.startsWith("-")) {
|
||||
instruction.key = childKey.substring(1);
|
||||
instruction.index = isIndexed(instruction.key);
|
||||
//如果是删除多列 diff数据的key都是-1 ,会把数据给覆盖,所以这里 ke+下标 做新的index
|
||||
instruction.index = isIndexed(instruction.key) == 1 ? isIndexed(instruction.key) + i : isIndexed(instruction.key);
|
||||
instruction.oper = Oper.DELETE;
|
||||
} else if (childKey.startsWith("+")) {
|
||||
instruction.key = childKey.substring(1);
|
||||
|
|
Loading…
Reference in New Issue