接口新增校验匹配条件
This commit is contained in:
parent
ac952deb8a
commit
4b4d4cd2b7
@ -200,7 +200,7 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer
|
||||
}
|
||||
if (CollUtil.isNotEmpty(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();
|
||||
mock.setInterfaceId(interfaceInfoId);
|
||||
mock.setHttpStatus(mockDTO.getHttpStatus());
|
||||
@ -216,34 +216,30 @@ public class GatewayInterfaceInfoServiceImpl implements IGatewayInterfaceInfoSer
|
||||
}
|
||||
|
||||
private void checkInsertGatewayInterfaceMockList(List<InsertGatewayInterfaceMockDTO> 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<MockMatchCondition> 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<MockMatchCondition> 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;
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user