Commit 995ec5c2 by inrgihc

测试问题修复

parent 037c07d6
package com.gitee.sqlrest.common.dto;
import com.gitee.sqlrest.common.enums.HttpMethodEnum;
import com.gitee.sqlrest.common.enums.ParamTypeEnum;
import com.gitee.sqlrest.common.exception.CommonException;
import com.gitee.sqlrest.common.exception.ResponseErrorCode;
......@@ -21,11 +22,15 @@ public class ItemParam extends BaseParam {
@ApiModelProperty("Object类型的子元素")
private List<BaseParam> children;
public void checkValid() {
public void checkValid(HttpMethodEnum method) {
if (StringUtils.isBlank(getName())) {
throw new CommonException(ResponseErrorCode.ERROR_INTERNAL_ERROR, "input parameter name must is not blank");
}
if (getType() == ParamTypeEnum.OBJECT) {
if (!method.isHasBody()) {
throw new CommonException(ResponseErrorCode.ERROR_INVALID_ARGUMENT,
"Request with GET/HEAD method cannot have object input parameter as body.");
}
if (null != children && children.size() > 0) {
for (BaseParam param : children) {
if (StringUtils.isBlank(param.getName())) {
......
......@@ -89,8 +89,7 @@ public class ApiExecuteService {
}
return result;
} else {
ResultEntity result = doExecute(getDataSourceEntity(config), config, paramValues);
return ResultEntity.success(result);
return doExecute(getDataSourceEntity(config), config, paramValues);
}
} catch (CommonException e) {
return ResultEntity.failed(e.getCode(), e.getMessage());
......
......@@ -336,7 +336,7 @@ public class ApiAssignmentService {
}
for (ItemParam itemParam : request.getParams()) {
itemParam.checkValid();
itemParam.checkValid(request.getMethod());
}
}
if (!CollectionUtils.isEmpty(request.getOutputs())) {
......@@ -437,7 +437,7 @@ public class ApiAssignmentService {
}
}
for (ItemParam itemParam : request.getParams()) {
itemParam.checkValid();
itemParam.checkValid(exists.getMethod());
}
}
if (!CollectionUtils.isEmpty(request.getOutputs())) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment