I have a Group entity that represents Groups (of users) in a database. The GroupRepository class has some methods that allow me to query the Group table, like, for example:
List<Group> findByGroupName(String name);
This method has a URL that's exposed when I curl the URL is the immediate parent of that method, i.e.:
curl http://localhost:8080/groups/search/
{
"_links" : {
"searchNames" : {
"href" : "http://localhost:8080/groups/search/seachNames{?terms}",
"templated" : true
},
"findByName" : {
"href" : "http://localhost:8080/groups/search/findByName{?name}",
"templated" : true
}
}
I am also building a controller to add additional REST endpoints, and I want them to be exposed just like above as "_links". How do make my methods appear like so?
UPDATE
Here is some of my repository code.
@Transactional(readOnly=true)
public interface GroupRepository extends PagingAndSortingRepository<Group, Long> {
Group findByName(@Param("name") String name);
@Query(value="SELECT * FROM `Group` WHERE name LIKE CONCAT('%',:terms,'%') ORDER BY CASE WHEN name = :terms THEN 0 WHEN name LIKE CONCAT(:terms,'%') THEN 1 WHEN name LIKE CONCAT('%',:terms,'%') THEN 2 WHEN name LIKE CONCAT('%',:terms) THEN 3 END",
nativeQuery=true)
List<Group> searchNames(@Param("terms") String terms);
}