@NotEmpty使用

@Data
public class ArtListHCG {
    // name
    @NotEmpty(message = "name不能为空")
    private String name;
}

@RestController
@RequestMapping("/test")
@Api(tags = "test查询")
@Validated// 一定要加上否则不生效
public class ArtListHCGController {
    @Resource
    private TestService TestService;

    @GetMapping("/name")
    @ApiOperation("测试")
    public ArtListHCG getUserById(@Valid ArtListHCG artListHCG) {
        return TestService.select(artListHCG.getOId(),artListHCG.getArtType());
    }
}

你可能感兴趣的:(java)