diff --git a/src/main/java/com/example/demo/Controller.java b/src/main/java/com/example/demo/Controller.java index 328ecfb..3ba73da 100644 --- a/src/main/java/com/example/demo/Controller.java +++ b/src/main/java/com/example/demo/Controller.java @@ -2,6 +2,7 @@ package com.example.demo; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; @@ -54,6 +55,14 @@ public class Controller { return "ID "+id+" does not exist!"; } } + @PatchMapping("/data/{id}") + public Object _6(@PathVariable Long id,@RequestBody Data data) { + if (database.existsById(id)) { + return database.save(data); + } else { + return "ID "+id+" does not exist!"; + } + } @DeleteMapping("/data/{id}") public String _4(@PathVariable Long id) { if (database.existsById(id)) {