这两个注解都不能缺少,开始缺少了下面hibernate的注解,导致校验一直不能生效。
package com.inspur.project.incredit.domain;
import java.io.Serializable;
import java.util.Date;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
@Data
@ApiModel
public class SupplyChainFinance implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 企业名称
*/
@NotBlank(message = "企业名不能为空")
@Size(min = 2, max = 100, message = "企业名长度大于2个字符,且不能超过100个字符")
@ApiModelProperty(value = "企业名")
private String entName;
/**
* 联系人
*/
@NotBlank(message = "联系人姓名不能为空")
@Size(min = 2, max = 6, message = "请输入正确的联系人姓名")
@ApiModelProperty(value = "联系人姓名")
private String contacts;
/**
* 联系方式,手机号或邮箱
*/
@ApiModelProperty(value = "联系方式,手机号或邮箱")
private String contact;
/**
* 备注
*/
@ApiModelProperty(value = "备注")
private String remark;
/**
* 角色:核心企业0,供应商1,金融机构2
*/
@NotBlank(message = "角色不能为空")
@Size(min = 1, max = 1, message = "角色长度不正确")
@ApiModelProperty(value = "角色:核心企业0,供应商1,金融机构2")
private String role;
}
@PostMapping("/submitInfo")
@ApiOperation("供应链金融提交信息")
@Log(title = "提交信息", businessType = BusinessType.INSERT)
@RepeatSubmit(interval = 1000)
public AjaxResult submitInfo(@Validated @RequestBody SupplyChainFinance supplyChainFinance) throws Exception {
int i = financeService.insertSelective(supplyChainFinance);
if(1==i){
return AjaxResult.success("信息提交成功");
}else {
return AjaxResult.success("信息提交失败");
}
}
网友评论