Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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