Implement PATCH

master
Joshua Sigona 4 years ago
parent 5eb33db38e
commit 2f2be651b3
  1. 9
      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)) {

Loading…
Cancel
Save