@Valid 注解用法详解
参考:https://blog.csdn.net/sunnyzyq/article/details/103527380
@ApiOperation("用户注册")
@PostMapping("register")
public BizBaseResponse<Boolean> register(@RequestBody @Validated UserRequest userRequest) {
return userService.register(userRequest);
}
@Data
@ApiModel(description = "用户请求信息")
public class UserRequest {
/**
* 手机号
*/
@Pattern(regexp = "^[1][3,4,5,7,8][0-9]{9}$",message = "手机号码不合法")
@ApiModelProperty(value = "手机号")
private String phone;
/**
* 验证码
*/
@NotBlank(message = "验证码不能为空")
@ApiModelProperty(value = "验证码")
private String code;
/**
* 用户点击获取验证码的次数
*/
@ApiModelProperty(value = "用户点击获取验证码的次数")
private int checkCount;
/**
* shareId
*/
@NotBlank(message = "shareId不能为空")
@ApiModelProperty(value = "shareId")
private String shareId;
}
评论区