@NotNull 返回对应message
添加ExceptionHandler:
@ExceptionHandler(MethodArgumentNotValidException.class) public BaseResMessage handleArgumentNotValidException(MethodArgumentNotValidException e) { return new BaseResMessage().error204Return(e.getBindingResult().getFieldError().getDefaultMessage()); }
添加@Valid
@PostMapping("/auto") public BaseResMessage<AutoAuditOrderDTO> auto(@RequestBody @Valid AutoAuditDetialRequest request){ return otherService.autoAuditDetail(request.getOrderId()); }
添加@NotNull
@Data public class AutoAuditDetialRequest implements Serializable { @NotNull(message = "订单id不为空") private Long orderId; }