update route

pull/1/head
Matt Huntington 5 years ago
parent c12b290f0d
commit f841ad9d23

@ -7,6 +7,7 @@ import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.PathVariable;
@ -38,4 +39,12 @@ public class DemoApplication {
personRepository.deleteById(id);
return personRepository.findAll();
}
@PutMapping("/people/{id}")
public Iterable<Person> update(@PathVariable int id, @RequestBody Person personData) {
personData.setId(id);
personRepository.save(personData);
return personRepository.findAll();
}
}

Loading…
Cancel
Save