接口新增校验匹配条件
This commit is contained in:
parent
ac952deb8a
commit
4b4d4cd2b7
@ -200,7 +200,7 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer
|
|||||||
}
|
}
|
||||||
if (CollUtil.isNotEmpty(dto.getMockExpectations())) {
|
if (CollUtil.isNotEmpty(dto.getMockExpectations())) {
|
||||||
checkInsertGatewayInterfaceMockList(dto.getMockExpectations());
|
checkInsertGatewayInterfaceMockList(dto.getMockExpectations());
|
||||||
List<GatewayInterfaceMock> mockList = dto.getMockExpectations().stream().map(mockDTO ->{
|
List<GatewayInterfaceMock> mockList = dto.getMockExpectations().stream().map(mockDTO -> {
|
||||||
GatewayInterfaceMock mock = new GatewayInterfaceMock();
|
GatewayInterfaceMock mock = new GatewayInterfaceMock();
|
||||||
mock.setInterfaceId(interfaceInfoId);
|
mock.setInterfaceId(interfaceInfoId);
|
||||||
mock.setHttpStatus(mockDTO.getHttpStatus());
|
mock.setHttpStatus(mockDTO.getHttpStatus());
|
||||||
@ -216,16 +216,15 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void checkInsertGatewayInterfaceMockList(List<InsertGatewayInterfaceMockDTO> gatewayInterfaceMockList) {
|
private void checkInsertGatewayInterfaceMockList(List<InsertGatewayInterfaceMockDTO> gatewayInterfaceMockList) {
|
||||||
gatewayInterfaceMockList.forEach(mock ->{
|
gatewayInterfaceMockList.forEach(mock -> {
|
||||||
Assert.notNull(mock.getHttpStatus(),"HTTP状态码不能为空");
|
Assert.notNull(mock.getHttpStatus(), "HTTP状态码不能为空");
|
||||||
Assert.isTrue(JSONUtils.isJSONObject(mock.getMockResponse()), "请输入正确格式的默认响应信息");
|
Assert.isTrue(JSONUtils.isJSONObject(mock.getMockResponse()), "请输入正确格式的默认响应信息");
|
||||||
try {
|
|
||||||
List<MockMatchCondition> conditionDTOList = mock.getMatchConditions();
|
List<MockMatchCondition> conditionDTOList = mock.getMatchConditions();
|
||||||
Assert.notEmpty(conditionDTOList,"至少存在一条匹配条件");
|
Assert.notEmpty(conditionDTOList, "至少存在一条匹配条件");
|
||||||
conditionDTOList.forEach(condition -> {
|
conditionDTOList.forEach(condition -> {
|
||||||
MatchType matchType = MatchType.getByCode(condition.getMatchType());
|
MatchType matchType = MatchType.getByCode(condition.getMatchType());
|
||||||
Assert.notNull(matchType,"不支持的匹配类型");
|
Assert.notNull(matchType, "不支持的匹配类型");
|
||||||
switch (matchType){
|
switch (matchType) {
|
||||||
case IS_NULL:
|
case IS_NULL:
|
||||||
case NOT_NULL:
|
case NOT_NULL:
|
||||||
break;
|
break;
|
||||||
@ -233,17 +232,14 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer
|
|||||||
case LE:
|
case LE:
|
||||||
case GT:
|
case GT:
|
||||||
case GE:
|
case GE:
|
||||||
Assert.notEmpty(condition.getParameterValue(),"请输入参数值");
|
Assert.notEmpty(condition.getParameterValue(), "请输入参数值");
|
||||||
Assert.isTrue(NumberUtil.isNumber(condition.getParameterValue().get(0)),"大于、大于或等于、小于、小于或等于类型,参数值只能是数字");
|
Assert.isTrue(NumberUtil.isNumber(condition.getParameterValue().get(0)), "大于、大于或等于、小于、小于或等于类型,参数值只能是数字");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Assert.notEmpty(condition.getParameterValue(),"请输入参数值");
|
Assert.notEmpty(condition.getParameterValue(), "请输入参数值");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (Exception e) {
|
|
||||||
log.error("JSONUtils.isJSONArray catch \n" + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user