get user api

This commit is contained in:
haerong22
2020-11-26 18:01:23 +09:00
parent cf3f1b684c
commit 71481e070e
4 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
package com.example.restfulwebservice.user;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController
public class UserController {
private final UserDaoService userDaoService;
public UserController(UserDaoService userDaoService) {
this.userDaoService = userDaoService;
}
@GetMapping("/users")
public List<User> retrieveAllUsers() {
return userDaoService.findAll();
}
@GetMapping("/users/{id}")
public User retrieveUser(@PathVariable int id) {
return userDaoService.findOne(id);
}
}