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