formatting
This commit is contained in:
parent
97e7228ce6
commit
58ec657a05
|
@ -5,5 +5,4 @@ import org.springframework.data.repository.CrudRepository;
|
||||||
// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
|
// This will be AUTO IMPLEMENTED by Spring into a Bean called userRepository
|
||||||
// CRUD refers Create, Read, Update, Delete
|
// CRUD refers Create, Read, Update, Delete
|
||||||
|
|
||||||
public interface UserRepository extends CrudRepository<User, Integer> {
|
public interface UserRepository extends CrudRepository<User, Integer> {}
|
||||||
}
|
|
||||||
|
|
|
@ -18,8 +18,8 @@ public class DBResource {
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
@GetMapping(path = "/add") // Map ONLY GET Requests
|
@GetMapping(path = "/add") // Map ONLY GET Requests
|
||||||
public @ResponseBody
|
public @ResponseBody String addNewUser(
|
||||||
String addNewUser(@RequestParam final String name, @RequestParam final String email) {
|
@RequestParam final String name, @RequestParam final String email) {
|
||||||
// @ResponseBody means the returned String is the response, not a view name
|
// @ResponseBody means the returned String is the response, not a view name
|
||||||
// @RequestParam means it is a parameter from the GET or POST request
|
// @RequestParam means it is a parameter from the GET or POST request
|
||||||
|
|
||||||
|
@ -37,8 +37,7 @@ public class DBResource {
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping(path = "/get")
|
@GetMapping(path = "/get")
|
||||||
public @ResponseBody
|
public @ResponseBody User getUser(@RequestParam final int id) {
|
||||||
User getUser(@RequestParam final int id) {
|
|
||||||
// This returns a JSON or XML with the users
|
// This returns a JSON or XML with the users
|
||||||
return userRepository.findOne(id);
|
return userRepository.findOne(id);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue