I have my Entities with Spring Data JPA, but to generate stats about them, I use jOOQ in a Spring @Repository
.
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
}
}
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.
See this from docs
@Bean
public ResourceProcessor<Resource<Person>> personProcessor() {
return new ResourceProcessor<Resource<Person>>() {
@Override
public Resource<Person> process(Resource<Person> resource) {
resource.add(new Link("http://localhost:8080/people", "added-link"));
return resource;
}
};
}