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
| { | |
| "_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
| { | |
| "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
| { | |
| "username": "jsmith" | |
| } |
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") | |
| UserUsername findUsernameById(@Param("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
| /** | |
| * Only defines a {@link com.samkruglov.entities.User#username username}. | |
| */ | |
| public class UserUsername { | |
| private final String username; // getter & consctuctor | |
| // equals & hashcode | |
| } |
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
| { | |
| "name": "A", | |
| "_links": { | |
| "self": { | |
| "href": "http://localhost:8080/groups/1" | |
| }, | |
| "group": { | |
| "href": "http://localhost:8080/groups/1" | |
| }, | |
| "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
| { | |
| "_links" : { | |
| "groups" : { | |
| "href" : "http://localhost:8080/groups" | |
| }, | |
| "users" : { | |
| "href" : "http://localhost:8080/users" | |
| }, | |
| "profile" : { | |
| "href" : "http://localhost:8080/profile" |
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 GroupRepository extends CrudRepository<Group, Long> {} |
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> {} |