|
@@ -0,0 +1,24 @@
|
|
1
|
+package com.example.demo.user;
|
|
2
|
+
|
|
3
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
4
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
5
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
6
|
+import org.springframework.web.bind.annotation.RestController;
|
|
7
|
+
|
|
8
|
+import java.util.List;
|
|
9
|
+
|
|
10
|
+@RestController
|
|
11
|
+public class UserController {
|
|
12
|
+ @Autowired
|
|
13
|
+ private UserRepository userRepository;
|
|
14
|
+
|
|
15
|
+ @RequestMapping(path="/users/search")
|
|
16
|
+ public User getUserByName(@RequestParam("name") String name) {
|
|
17
|
+ return userRepository.findByName(name);
|
|
18
|
+ }
|
|
19
|
+
|
|
20
|
+ @RequestMapping(path="/users/active")
|
|
21
|
+ public List<User> getActiveUser() {
|
|
22
|
+ return userRepository.findAllByActive(true);
|
|
23
|
+ }
|
|
24
|
+}
|