如何在springboot中解析postman的json并存储在h2中

ndh0cuux  于 2021-07-23  发布在  Java
关注(0)|答案(0)|浏览(216)

事件repo json结构:

{
    "id": 2021,
    "type": "PushEvent",
    "actor": {
        "id": 2021,
        "login": "sam",
         "avatar_url": "https://avatars.com/sam"
    },
    "repo": {
         "id": 2021,
         "name": "padi/mag",
        "url": "https://github.com/pad/mag"
    },
     "created_at": "2021-12-29 20:31:36"
 }
@Entity
public class Event {
    @Id
    private Long id;
    private String type;
    @Embedded
    private Actor actor;
    @Embedded
    private Repo repo;
    @CreationTimestamp
    private Timestamp createdAt;
}
@Data
@Embeddable
public class Actor {
    @Id
    @Column(unique = true)
    private Long id;
    @Column(unique = true)
    private String login;
    private String avatar;
}

@Data
@Embeddable
public class Repo {
    @Id
    @Column(unique = true)
    private Long id;
    private String name;
    private String url;
}

This is how the DB is created:

ID      AVATAR LOGIN    CREATED_AT           NAME       URL                        TYPE  
20211   null   sam1 2021-02-17 19:45:32.627 padi/mag    https://github.com/pad/mag  PushEvent

如何将上述事件json结构添加到h2数据库中
同时,我还想把
内容类型(mediatype.application\u json\u utf8),
内容(json)和响应状态
有人能在 java 帮忙吗?

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题