如何简单地添加到Spring Data REST实体的链接 [英] How can I simply add a link to a Spring Data REST Entity
问题描述
我拥有使用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
.
由于我的方法返回的是实体的List
或Double
,如何将它们公开为链接?假设我有一个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屋!