我做了一个代码,在我的本地主机上添加了注释:3000,但是它解析了很多信息,所以我想删除“ commentModel”,但是如果我从CommentRq类中删除它,则会出现错误 { “ commentModel”:{ “ comment”:“ komentarz”, “日期”:“ 19年3月6日上午9:34” }, “ id”:666 } ]
CommentRq
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public class CommentRq {
@JsonProperty(access = JsonProperty.Access.READ_ONLY)
private CommentModel commentModel;
@AllArgsConstructor
@NoArgsConstructor
@Data
@Builder
public static class CommentModel {
@JsonProperty("comment")
String resourceName;
@JsonProperty("date")
String resourceNamed;
}
}
CommentBody
public class CommentBody {
Date now = new Date();
@JsonInclude(JsonInclude.Include.NON_NULL)
public CommentRq RequestCommentBody() {
return CommentRq.builder()
.commentModel(new CommentRq.CommentModel(
"komentarz",
(DateFormat.getInstance().format(now))
))
.build();
}
}