From 4b4d4cd2b7d6958ae8ac7b43b3c01a7c3b1509e1 Mon Sep 17 00:00:00 2001 From: akun <957746831@qq.com> Date: Tue, 21 May 2024 17:56:07 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E6=96=B0=E5=A2=9E=E6=A0=A1?= =?UTF-8?q?=E9=AA=8C=E5=8C=B9=E9=85=8D=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/GatewayInterfaceInfoServiceImpl.java | 52 +++++++++---------- 1 file changed, 24 insertions(+), 28 deletions(-) diff --git a/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java b/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java index 3ea3c8b..4b86526 100644 --- a/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java +++ b/sf-service/src/main/java/com/sf/service/gateway/service/impl/GatewayInterfaceInfoServiceImpl.java @@ -200,7 +200,7 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer } if (CollUtil.isNotEmpty(dto.getMockExpectations())) { checkInsertGatewayInterfaceMockList(dto.getMockExpectations()); - List mockList = dto.getMockExpectations().stream().map(mockDTO ->{ + List mockList = dto.getMockExpectations().stream().map(mockDTO -> { GatewayInterfaceMock mock = new GatewayInterfaceMock(); mock.setInterfaceId(interfaceInfoId); mock.setHttpStatus(mockDTO.getHttpStatus()); @@ -216,34 +216,30 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer } private void checkInsertGatewayInterfaceMockList(List gatewayInterfaceMockList) { - gatewayInterfaceMockList.forEach(mock ->{ - Assert.notNull(mock.getHttpStatus(),"HTTP状态码不能为空"); + gatewayInterfaceMockList.forEach(mock -> { + Assert.notNull(mock.getHttpStatus(), "HTTP状态码不能为空"); Assert.isTrue(JSONUtils.isJSONObject(mock.getMockResponse()), "请输入正确格式的默认响应信息"); - try { - List conditionDTOList = mock.getMatchConditions(); - Assert.notEmpty(conditionDTOList,"至少存在一条匹配条件"); - conditionDTOList.forEach(condition -> { - MatchType matchType = MatchType.getByCode(condition.getMatchType()); - Assert.notNull(matchType,"不支持的匹配类型"); - switch (matchType){ - case IS_NULL: - case NOT_NULL: - break; - case LT: - case LE: - case GT: - case GE: - Assert.notEmpty(condition.getParameterValue(),"请输入参数值"); - Assert.isTrue(NumberUtil.isNumber(condition.getParameterValue().get(0)),"大于、大于或等于、小于、小于或等于类型,参数值只能是数字"); - break; - default: - Assert.notEmpty(condition.getParameterValue(),"请输入参数值"); - break; - } - }); - } catch (Exception e) { - log.error("JSONUtils.isJSONArray catch \n" + e.getMessage()); - } + List conditionDTOList = mock.getMatchConditions(); + Assert.notEmpty(conditionDTOList, "至少存在一条匹配条件"); + conditionDTOList.forEach(condition -> { + MatchType matchType = MatchType.getByCode(condition.getMatchType()); + Assert.notNull(matchType, "不支持的匹配类型"); + switch (matchType) { + case IS_NULL: + case NOT_NULL: + break; + case LT: + case LE: + case GT: + case GE: + Assert.notEmpty(condition.getParameterValue(), "请输入参数值"); + Assert.isTrue(NumberUtil.isNumber(condition.getParameterValue().get(0)), "大于、大于或等于、小于、小于或等于类型,参数值只能是数字"); + break; + default: + Assert.notEmpty(condition.getParameterValue(), "请输入参数值"); + break; + } + }); }); }