entity
多个接口共用该vo 校验就该分组了 get save 分组用内部接口即可
public class TestVo {
public interface ValidGetTest{}
public interface ValidSaveTest{}
private Integer id;
private String str;
@NotBlank(groups = {ValidGetTest.class})
private String str;
@NotEmpty(groups = {ValidSaveTest.class})
private Integer[] ids;
}
用的时候在controller 将对应的分组class给校验即可 如图
public ResData getTest(@Validated(TestVo.ValidGetTest.class) TestVo testVo) {
return testService.getTest(test);
}