浏览代码

Test failed. Still trying to work out secured endpoints

JaseG256 6 年前
父节点
当前提交
8628192275
共有 1 个文件被更改,包括 8 次插入8 次删除
  1. 8
    8
      ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/UserController.java

+ 8
- 8
ZipTeamOrange-server/src/main/java/ZipTeamOrange/Controller/UserController.java 查看文件

@@ -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
 }