Last active
March 28, 2018 03:08
-
-
Save aarshtalati/ca16401fa5dbe696d770272c3752a573 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package edu.gatech.epidemics.api; | |
import edu.gatech.epidemics.model.User; | |
import edu.gatech.epidemics.service.UserService; | |
import org.springframework.beans.factory.annotation.Autowired; | |
import org.springframework.core.env.Environment; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.PathVariable; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
import java.net.InetAddress; | |
import java.net.UnknownHostException; | |
import java.time.LocalDateTime; | |
import java.time.format.DateTimeFormatter; | |
import java.util.List; | |
/** | |
* @author atalati | |
* /api/user | |
*/ | |
@RestController | |
public class UserApiController { | |
@Autowired | |
Environment environment; | |
@Autowired | |
private UserService userService; | |
/* | |
GET: /api/user/ | |
Returns all users from the database | |
*/ | |
@GetMapping(value = "/api/user") | |
public List<User> get() { | |
return userService.findAll(); | |
} | |
@GetMapping(value = "/api/user/{id}") | |
public User get(@PathVariable int id) { | |
return userService.findById(id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment