问题
@Data
@Accessors(chain = true)
public class CreateTemplateReq {
@ApiModelProperty(value = "**名称")
@Pattern(regexp = "^.{0,100}", message = "名称长度不可超过100")
@NotBlank(message = "**名称必填")
private String templateTitle;
@ApiModelProperty(value = "描述")
@Pattern(regexp = "^.{0,255}", message = "描述长度不可超过255")
@NotBlank(message = "描述必填")
private String templateDesc;
@ApiModelProperty(value = "类型")
@NotNull(message = "类型不能为空")
private Integer templateType;
@ApiModelProperty(value = "**")
private List<CreateTemplateStagesReq> stages;
}
@Data
@Accessors(chain = true)
public class CreateTemplateStagesReq {
@ApiModelProperty(value = "**名称")
@Pattern(regexp = "^.{0,20}", message = "**名称长度不可超过20")
private String stageTitle;
@ApiModelProperty(value = "**描述")
@Pattern(regexp = "^.{0,255}", message = "描述长度不可超过255")
private String stageDesc;
@ApiModelProperty(value = "****")
private Integer formType;
@ApiModelProperty(value = "**索引")
private Integer templateStageIndex;
@ApiModelProperty(value = "**")
private List<CreateTemplateDeliversReq> delivers;
}
多层嵌套对象,发现里面的对象 注解不生效
public Result create(@RequestBody @Valid CreateTemplateReq param) {
}
解决方法
@ApiModelProperty(value = "**")
@Valid
private List<CreateTemplateStagesReq> stages;
@ApiModelProperty(value = "**")
@Valid
private List<CreateTemplateDeliversReq> delivers;
这样就解决了