This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"username": "jsmith", | |
"firstName": "John", | |
"lastName": "Smith", | |
"_links": { | |
"self": { | |
"href": "http://localhost:8080/users/1" | |
}, | |
"user": { | |
"href": "http://localhost:8080/users/1" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_links": { | |
"getUsername": { | |
"href": "http://localhost:8080/users/search/username{?id}", | |
"templated": true | |
}, | |
"self": { | |
"href": "http://localhost:8080/users/search" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RepositoryRestController | |
public class UserController { | |
private final RepositoryEntityLinks links; | |
private final UserRepository userRepository; | |
// all arg constructor | |
@GetMapping("users/search/username") | |
public ResponseEntity<Resource<UserUsername>> addLinksToUserUsername(@RequestParam("id") Long id){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"username": "jsmith", | |
"_links": { | |
"self": { | |
"href": "http://localhost:8080/users/search/username{?id}", | |
"templated": true | |
}, | |
"user": { | |
"href": "http://localhost:8080/users/1" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface UserRepository extends CrudRepository<User, Long> { | |
@RestResource(path = "username", rel = "getUsername") | |
UserUsernameAndGroupName findUsernameAndGroupNameById(@Param("id") Long id); | |
interface UserUsernameAndGroupName { | |
String getUsername(); | |
default String getGroupName() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"username": "jsmith", | |
"groupName": "A" | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.samkruglov.entities.projections; | |
@Projection(name = "username-only", types = User.class) | |
public interface UserUsername { | |
String getUsername(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"username": "jsmith", | |
"firstName": "John", | |
"lastName": "Smith", | |
"_links": { | |
"self": { | |
"href": "http://localhost:8080/users/1" | |
}, | |
"user": { | |
"href": "http://localhost:8080/users/1{?projection}", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"_embedded": { | |
"users": [] | |
}, | |
"_links": { | |
"self": { | |
"href": "http://localhost:8080/users" | |
}, | |
"profile": { | |
"href": "http://localhost:8080/profile/users" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"alps": { | |
"version": "1.0", | |
"descriptors": [ | |
{ | |
"id": "get-users", | |
"name": "users", | |
"type": "SAFE", | |
"rt": "#user-representation", | |
"descriptors": [ |