|
@@ -7,6 +7,8 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
7
|
7
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
8
|
import org.springframework.web.bind.annotation.*;
|
9
|
9
|
|
|
10
|
+import java.util.Optional;
|
|
11
|
+
|
10
|
12
|
@RestController
|
11
|
13
|
@RequestMapping(path = "/user")
|
12
|
14
|
public class UserController {
|
|
@@ -23,16 +25,14 @@ public class UserController {
|
23
|
25
|
return ob.writeValueAsString(user);
|
24
|
26
|
}
|
25
|
27
|
|
26
|
|
- @GetMapping(path="/all")
|
27
|
|
- public @ResponseBody Iterable<User> getAllUser(){
|
28
|
|
- //this returns a JSON or XML with users
|
29
|
|
- return userRepository.findAll();
|
|
28
|
+ @GetMapping(path="/userName")
|
|
29
|
+ public Optional<User> findByUserName(@RequestParam("name") String userName) {
|
|
30
|
+ return userRepository.findByUsername(userName);
|
30
|
31
|
}
|
31
|
32
|
|
32
|
|
- @GetMapping(path="/all")
|
33
|
|
- public @ResponseBody Iterable<User> getAllUser(){
|
34
|
|
- //this returns a JSON or XML with users
|
35
|
|
- return userRepository.findAll();
|
|
33
|
+ @GetMapping(path="/email")
|
|
34
|
+ public Optional<User> findByEmail(@RequestParam("email") String email) {
|
|
35
|
+ return userRepository.findByEmail(email);
|
36
|
36
|
}
|
37
|
37
|
|
38
|
38
|
}
|