-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserController.java
More file actions
34 lines (26 loc) · 973 Bytes
/
UserController.java
File metadata and controls
34 lines (26 loc) · 973 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package com.getdata.restcall_test1.Controller;
import com.getdata.restcall_test1.Entity.Books;
import com.getdata.restcall_test1.Entity.User;
import com.getdata.restcall_test1.Service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@RestController
@RequestMapping("/users")
public class UserController {
private UserService userService;
public UserController(UserService userService){
this.userService = userService;
}
@GetMapping("/getUser/{Username}")
public ResponseEntity<List<User>> getUsersByUsername(@PathVariable String Username) {
List<User> users = userService.getUsersByUsername(Username);
return ResponseEntity.ok(users);
}
@PostMapping("/postUser")
public User postUser(User user){
userService.postUser(user);
return user;
}
}