@Validated多层校验,不去读文档,在往上东拼西凑,知道这么个东西挺好用。
但是如何去校验对象参数的属性就犯难了。
百度了一下—
是它,是它,就是它 ╮( ̄▽  ̄)╭ @Valid
request
public class xxxxxxxxxxxRequest implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank(message = "xxxx不能为空")
private String bidSeq;
@NotBlank(message = "xxxxxx不能为空")
private String quoteSeq;
@Valid
private QuotePrice quotePrice;
@Valid
private List<QuotePrice> quotePrices;
public static class QuotePrice implements Serializable {
private static final long serialVersionUID = 1L;
@NotBlank(message = "报价单项号不能为null")
private String quoteItemSeq;
@NotNull(message = "报价类型不能为null")
private Integer priceType;
@NotBlank(message = "报价金额不能为null")
private String price;
}
}
controller
@RequestMapping("/xxxxx")
public Result<Object> xxxxx(@Validated @RequestBody xxxxxxxxxxxRequest request){
return programBidProductService.xxxxx(request);
}