delete route

pull/1/head
Matt Huntington 5 years ago
parent ad4f77ade6
commit 126a01d43b

@ -6,8 +6,11 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.beans.factory.annotation.Autowired;
@SpringBootApplication @SpringBootApplication
@RestController @RestController
@ -21,12 +24,18 @@ public class DemoApplication {
@GetMapping("/people") @GetMapping("/people")
public Iterable<Person> index() { public Iterable<Person> index() {
return personRepository.findAll(); return personRepository.findAll();
} }
@PostMapping(path="/people") @PostMapping(path="/people")
public Iterable<Person> create (@RequestBody Person personData) { public Iterable<Person> create (@RequestBody Person personData) {
personRepository.save(personData); personRepository.save(personData);
return personRepository.findAll(); return personRepository.findAll();
} }
@DeleteMapping(value = "/people/{id}")
public Iterable<Person> delete(@PathVariable int id) {
personRepository.deleteById(id);
return personRepository.findAll();
}
} }

Loading…
Cancel
Save