如何简单地添加到Spring Data REST实体的链接 [英] How can I simply add a link to a Spring Data REST Entity

查看:154
本文介绍了如何简单地添加到Spring Data REST实体的链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我拥有使用Spring Data JPA的实体,但是要生成有关它们的统计信息,我在Spring @Repository中使用jOOQ.

I have my Entities with Spring Data JPA, but to generate stats about them, I use jOOQ in a Spring @Repository.

由于我的方法返回的是实体的ListDouble,如何将它们公开为链接?假设我有一个User实体,我想获取以下JSON:

Since my methods return either a List of entities, or a Double, how can I expose them as links? Let's say I have a User entity, I want to get the following JSON:

{
  "_embedded" : {
    "users" : [ ]
  },
  "_links" : {
    "self" : {
      "href" : "http://localhost:8080/api/users"
    },
    "stats" : {
      "href" : "http://localhost:8080/api/users/stats"
    }
    "profile" : {
      "href" : "http://localhost:8080/api/profile/users"
    }
  },
  "page" : {
    "size" : 20,
    "totalElements" : 0,
    "totalPages" : 0,
    "number" : 0
  }
} 

http://localhost:8080/api/users/stats 中,我想获取与我在jOOQ存储库中声明的方法的链接列表.我将如何处理?谢谢.

And in http://localhost:8080/api/users/stats I want to get a list of links with the methods I declared in my jOOQ repository. How would I approach this? Thanks.

推荐答案

请参见

这篇关于如何简单地添加到Spring Data REST实体的链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆