From 2306bfda7391b3248d4632b2945335503cb168ee Mon Sep 17 00:00:00 2001 From: guoyuqi Date: Thu, 21 Jul 2022 17:44:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=8E=A5=E5=8F=A3=E6=B5=8B=E8=AF=95):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A5=E5=8F=A3=E5=AF=BC=E5=85=A5=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E5=8F=98=E5=8C=96=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --user=郭雨琦 --bug=1014707 https://www.tapd.cn/55049933/bugtrace/bugs/view/1155049933001014707 --- .../api/service/ApiDefinitionService.java | 53 +++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java index c47b05bc11..8a3c153505 100644 --- a/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java +++ b/backend/src/main/java/io/metersphere/api/service/ApiDefinitionService.java @@ -1207,7 +1207,9 @@ public class ApiDefinitionService { } if (!StringUtils.equals(apiDefinition.getTags(), existApi.getTags())) { - return true; + if (apiDefinition.getTags() != null && Objects.equals(apiDefinition.getTags(), "") && existApi.getTags() != null && Objects.equals(existApi.getTags(), "")) { + return true; + } } if (!StringUtils.equals(existApi.getRemark(), apiDefinition.getRemark())) { @@ -1218,8 +1220,53 @@ public class ApiDefinitionService { return true; } - if (!StringUtils.equals(existApi.getResponse(), apiDefinition.getResponse())) { - return true; + JsonNode exApiResponse = null; + JsonNode apiResponse = null; + try { + exApiResponse = objectMapper.readTree(existApi.getResponse()); + apiResponse = objectMapper.readTree(apiDefinition.getResponse()); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + + if (exApiResponse == null || apiResponse == null) { + return false; + } + + if (exApiResponse.get("headers") != null && apiResponse.get("headers") != null) { + if (!StringUtils.equals(exApiResponse.get("headers").toString(), apiResponse.get("headers").toString())) { + return true; + } + } + + if (exApiResponse.get("type") != null && apiResponse.get("type") != null) { + if (!StringUtils.equals(exApiResponse.get("type").toString(), apiResponse.get("type").toString())) { + return true; + } + } + + if (exApiResponse.get("name") != null && apiResponse.get("name") != null) { + if (!StringUtils.equals(exApiResponse.get("name").toString(), apiResponse.get("name").toString())) { + return true; + } + } + + if (exApiResponse.get("body") != null && apiResponse.get("body") != null) { + if (!StringUtils.equals(exApiResponse.get("body").toString(), apiResponse.get("body").toString())) { + return true; + } + } + + if (exApiResponse.get("statusCode") != null && apiResponse.get("statusCode") != null) { + if (!StringUtils.equals(exApiResponse.get("statusCode").toString(), apiResponse.get("statusCode").toString())) { + return true; + } + } + + if (exApiResponse.get("enable") != null && apiResponse.get("enable") != null) { + if (!StringUtils.equals(exApiResponse.get("enable").toString(), apiResponse.get("enable").toString())) { + return true; + } } JsonNode exApiRequest = null;