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; + } + }); }); }