部门管理接口入参检查完善

This commit is contained in:
gaoqr
2024-10-14 09:28:00 +08:00
parent e0064d3166
commit a6efb5867e
6 changed files with 82 additions and 6 deletions
@@ -135,7 +135,12 @@ public class GlobalExceptionHandler {
log.warn("[handleBindException]", ex);
FieldError fieldError = ex.getFieldError();
assert fieldError != null; // 断言,避免告警
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数不正确:%s", fieldError.getRejectedValue()));
String defaultMessage = fieldError.getDefaultMessage();
if (CharSequenceUtil.isNotEmpty(defaultMessage)) {
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数不正确:%s", defaultMessage));
} else {
return CommonResult.error(BAD_REQUEST.getCode(), String.format("请求参数不正确:%s", fieldError.getRejectedValue()));
}
}
/**