diff --git a/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java b/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java index 0ed2313fa2..37dce7733b 100644 --- a/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java +++ b/backend/src/main/java/io/metersphere/log/utils/ReflexObjectUtil.java @@ -1,6 +1,7 @@ package io.metersphere.log.utils; import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; @@ -59,7 +60,7 @@ public class ReflexObjectUtil { column.setDepthDff(true); if (val != null) { try { - if (f.getName().equals("loadConfiguration")) { + if (ReflexObjectUtil.isJsonArray(val.toString())) { val = "{\"" + "压力配置" + "\":" + val.toString() + "}"; } Gson gson = new GsonBuilder().setPrettyPrinting().create(); @@ -82,6 +83,18 @@ public class ReflexObjectUtil { return columnList; } + public static boolean isJsonArray(String content) { + try { + JSONArray array = JSON.parseArray(content); + if (array != null && array.size() > 0) { + return true; + } + return false; + } catch (Exception e) { + return false; + } + } + public static void order(List orderRegulation, List targetList) { Collections.sort(targetList, ((o1, o2) -> { int io1 = orderRegulation.indexOf(o1.getColumnName()); @@ -98,6 +111,15 @@ public class ReflexObjectUtil { List newColumns = newObj.getColumns(); for (int i = 0; i < originalColumns.size(); i++) { if (!StringUtils.equals(JSON.toJSONString(originalColumns.get(i).getOriginalValue()), JSON.toJSONString(newColumns.get(i).getOriginalValue()))) { + if (originalColumns.get(i).getColumnName().equals("tags")) { + if ((originalColumns.get(i).getOriginalValue() == null || StringUtils.isEmpty(originalColumns.get(i).getOriginalValue().toString())) + && StringUtils.equals("[]", newColumns.get(i).getOriginalValue().toString())) { + continue; + } else if ((newColumns.get(i).getOriginalValue() == null || StringUtils.isEmpty(newColumns.get(i).getOriginalValue().toString())) + && StringUtils.equals("[]", originalColumns.get(i).getOriginalValue().toString())) { + continue; + } + } // 深度对比 if (originalColumns.get(i).isDepthDff() && originalColumns.get(i).getOriginalValue() != null && newColumns.get(i).getOriginalValue() != null) { ObjectMapper mapper = new ObjectMapper(); @@ -123,13 +145,13 @@ public class ReflexObjectUtil { } StringBuilder newValue = new StringBuilder(); if (addBuff != null && addBuff.toString().length() > 0) { - newValue.append("添加:").append(addBuff).append("\n"); + newValue.append("添加:\n").append(addBuff).append("\n"); } if (removeBuff != null && removeBuff.toString().length() > 0) { - newValue.append("移除:").append(removeBuff).append("\n"); + newValue.append("移除:\n").append(removeBuff).append("\n"); } if (repBuff != null && repBuff.toString().length() > 0) { - newValue.append("修改:").append(repBuff).append("\n"); + newValue.append("修改:\n").append(repBuff).append("\n"); } DetailColumn column = new DetailColumn(); BeanUtils.copyBean(column, originalColumns.get(i)); diff --git a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue index 3e49bb0572..8b1cea2371 100644 --- a/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue +++ b/frontend/src/business/components/api/automation/scenario/EditApiScenario.vue @@ -651,6 +651,9 @@ recursiveSorting(arr, scenarioProjectId) { for (let i in arr) { arr[i].index = Number(i) + 1; + if (!arr[i].resourceId) { + arr[i].resourceId = getUUID(); + } if (arr[i].type === ELEMENT_TYPE.LoopController && arr[i].loopType === "LOOP_COUNT" && arr[i].hashTree && arr[i].hashTree.length > 1) { arr[i].countController.proceed = true; } @@ -677,6 +680,9 @@ for (let i in this.scenarioDefinition) { // 排序 this.scenarioDefinition[i].index = Number(i) + 1; + if (!this.scenarioDefinition[i].resourceId) { + this.scenarioDefinition[i].resourceId = getUUID(); + } // 设置循环控制 if (this.scenarioDefinition[i].type === ELEMENT_TYPE.LoopController && this.scenarioDefinition[i].hashTree && this.scenarioDefinition[i].hashTree.length > 1) { diff --git a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue index fc8ca9131f..8973f39193 100644 --- a/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue +++ b/frontend/src/business/components/api/automation/scenario/component/ApiComponent.vue @@ -310,6 +310,9 @@ for (let i in arr) { arr[i].disabled = true; arr[i].index = Number(i) + 1; + if (!arr[i].resourceId) { + arr[i].resourceId = getUUID(); + } if (arr[i].hashTree != undefined && arr[i].hashTree.length > 0) { this.recursiveSorting(arr[i].hashTree); } @@ -317,6 +320,9 @@ }, sort() { for (let i in this.request.hashTree) { + if (!this.request.hashTree[i].resourceId) { + this.request.hashTree[i].resourceId = getUUID(); + } this.request.hashTree[i].disabled = true; this.request.hashTree[i].index = Number(i) + 1; if (this.request.hashTree[i].hashTree != undefined && this.request.hashTree[i].hashTree.length > 0) { @@ -368,7 +374,7 @@ /*触发执行操作*/ this.reportId = getUUID(); }, - errorRefresh(){ + errorRefresh() { this.loading = false; }, runRefresh(data) { diff --git a/frontend/src/business/components/api/definition/components/ApiKeyValue.vue b/frontend/src/business/components/api/definition/components/ApiKeyValue.vue index ad36eb17d7..66ec21ee16 100644 --- a/frontend/src/business/components/api/definition/components/ApiKeyValue.vue +++ b/frontend/src/business/components/api/definition/components/ApiKeyValue.vue @@ -44,7 +44,6 @@ show-word-limit> - @@ -53,6 +52,7 @@ +