Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class UserController {
@Autowired
private UserService userService;

@PostMapping("/user")
@PostMapping("/users")
public ResponseEntity<User> createUser(@RequestBody User user){
return new ResponseEntity<>(userService.createUser(user), HttpStatus.CREATED);
}
Expand All @@ -23,6 +23,11 @@ public ResponseEntity<User> findUserById(@PathVariable Long id){
return new ResponseEntity<>(userService.findUserById(id), HttpStatus.OK);
}

@GetMapping("/users")
public ResponseEntity<Iterable<User>> findUsers(){
return new ResponseEntity<>(userService.findUsers(), HttpStatus.OK);
}

@PutMapping("/user/update/{id}")
public ResponseEntity<User> updateUser (@PathVariable Long id, @RequestBody User user){
return new ResponseEntity<>(userService.updateUser(id, user), HttpStatus.OK);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/finance/zipBank/Service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,12 @@ public class UserService {
//finds user by ID
public User findUserById(Long id){
return userRepo.findById(id).get();
}

public Iterable<User> findUsers(){
return userRepo.findAll();
}

//creates user
public User createUser(User user){
User newUser = new User();
Expand Down